[Zope] dtml methods and namespace

Dieter Maurer dieter at handshake.de
Thu Mar 9 14:01:59 EST 2006


Luca Dall'Olio wrote at 2006-3-9 11:47 +0100:
>I have a simple dtml-method "assignment-action" that is called upon a 
>form post.
>Depending on the form request data, a <dtml-if> chooses between one of 
>two dtml-documents : "assigment-success" and "assignment-failure" :
>
><dtml-if  "iscorrect()">
> <dtml-var assignment-success>
><dtml-else>
> <dtml-var assignment-failure>
></dtml-if>
>
>My trouble is that neither the "assignment-success" nor the 
>"assignment-failure" dtml-documents seem to be pushed on the namespace : 
>inside them title_or_id references data from their caller

That is strange. In fact, a "DTMLDocument" (unlike a "DTMLMethod"!)
extends the passed in client by "self.aq_explicit".
Note, that due to the use of "aq_explicit", acquisition through
your "DTMLDocument" is restricted.

> this() and 
>PARENTS do not evaluate right...

"PARENTS" is set after the traversal phase. Lateron, it is not changed --
e.g. not changed by calls of DMTL objects.

>is there a smarter way to call a 
>dtml-document inside a dtml-method (), so that it it pushed on the 
>namespace stack?

It should be pushed automatically (as long as it is really a
"DTMLDocument".

Of course, you can control the context yourself, e.g. by

   <dtml-var "doc(doc,_)">

In this case, you pass "doc" (assumed to be your DTML document)
explicitly as client.

-- 
Dieter


More information about the Zope mailing list