[Zope-dev] Setting vars in expression eval() namespace

Dieter Maurer dieter@handshake.de
Thu, 22 Feb 2001 20:50:39 +0100 (CET)


Julio Maia writes:
 > I'm trying to create a tag to evaluate the expression passed to it, adding in the expression eval namespace a variable that contains the result of dtml processing of the tag's block. For instance, the following construct:
 > 
 > <dtml-bvar "foo(a=1)" var="block">
 >    some text <dtml-var "1+2">
 > </dtml-bvar>
 > 
 > would invoke the expression "foo(a=1)" with a variable named 'block' set to 'some text 3' in the expression's namespace (btw, is it possible to achieve this using regular dtml?).
What a construction! I do not like it.

 > However, I couldn't find a way to set a variable in the namespace used in the evaluation of the expression. I've tried to insert an entry in the mappings passed to the expression eval() method as follows:
Push a new mapping onto the namespace (with its "push" method).
Do not forget, to pop it after your tag.


Dieter