[Zope-dev] Setting/Creating variables

James A. Hillyerd jamesh@altavista.net
Wed, 10 Mar 1999 11:53:40 -0800 (PST)


I posted something similar to the zope list, but this is a different
message, so don't skip it, you probably haven't read it already! =)

I have been playing around with Zope/ZPublisher/DocumentTemplate and have
been extremely pleased with the ease of development, as well as the power
of the Python language.

Sometimes I have found myself wanting to save the results of an expression
in my DTML code, for use later in the same page (or even an embedded DTML
object).  The only thing I have used that is similar to DTML is
ColdFusion, which has a CFSET tag, ie: <cfset myvar = "test"> or
<cfset total = subtotal * tax>

After being pointed to the FAQ, I can see the recommended way to do this
is <!--#call "REQUEST.set('var', 'value')-->  This is pretty ugly looking
IMHO, and not really in the spirit of Zope, since DTML is supposed to be
elegant and simple.  (at least that was my impression of DTML's goals)

I understand that having a #set command that adds values to the REQUEST
object would be difficult, since you don't actually have to pass in a
REQUEST to a Template when you call it.

It's been a while since I've read the CF manuals, but I remember it having
three or more namespaces, including: request/system variables, user
defined variables, database query variables...  It would be nice if a user
defined variables namespace could be created inside a template (and
attached to REQUEST if available?), and passed on to any embedded DTML
calls.

Then inside DTML documents there could be a set command, similar to:

<!--#set var1=anotherVar var2="expr"-->

or

<!--#set name=var1 value=anotherVar-->
<!--#set name=var2 value="expr"-->

(I'm not sure which syntax would be more in the spirit of DTML)

The lifespan of the variables should only be that of the current request,
they should not be attached to a session, or have any effect on any other
REQUEST's variables.

Anyways, I wanted to bounce this idea off of the Digicool people, and
other long-time Zope users to find out if this is a good thing or a bad
thing.  It seems like something that needs to be done IMHO, because Zope
are trying to appeal to ColdFusion users, many of which are looking for
something easy to develop in, without having to learn Python.  And
something like REQUEST.set(var, val) might look a lot like programming to
them.

-james

[]  James A. Hillyerd <jamesh@altavista.net> Java Developer
[]  HyperGlyphics:  http://www.hyperglyphics.com/
[]  GPG Public Key Fingerprint for 1024D/9F956CDE (Expires 2000-02-01):
[]   C86F B073 92DF 1E24 EF0B  0118 6061 0FEC 9F95 6CDE