[Zope] equivalent of eval in dtml ?
happyrhino@usa.net
happyrhino@usa.net
1 Sep 99 18:00:30 MDT
Answering my own question. I've realised that I was trying to do too
much within DTML by trying to import Python modules.
I thought wrongly that you could embed Python code within DTML (other
than the basic string and math services in _)
The solution seems to be to use external methods instead.
Using the same example =
>How to set a variable 'mytime' to the current time ?
>
><dtml-call "REQUEST.set('mytime', 'ZopeTime fmt=%H:%M')">
>
>sets it to the string 'ZopeTime fmt=%H:%M'
>
>Is there no equivalent of eval() ?
The solution was simply to create an external method called 'timenow'
to return the time.
Then use <dtml-call "REQUEST.set('mytime', timenow)">
In fact, external methods look like the way to go for a lot of data
massaging. For example, in my CGI programs I currently take the results
from a SQL query and run some of the fields through customised Python
functions to further format them. It seems that the best way to do this
with Zope is to write an external method for each function.
However, this does mean that I'm going to have dozens if not hundreds
of external methods; but at least they're easier to read than dtml.
Henry
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1