[Zope] reference to a DTML Document in a script called by this Document

Dieter Maurer dieter@handshake.de
Mon, 9 Dec 2002 22:53:28 +0100


Elena Schulz writes:
 > context in a script called from a DTML-Method refers to the containing
 > folder as expected. But context in a script called from a DTML-Document
 > refers also to the containing folder!? Shouldn'd that be the Document
 > itself?
Only, when you access the script via the document, e.g. in the
form "doc.script".

DTML Document tries to avoid acquisition through the document object
(it succeeds partially). In your case, it was successful.

 > Even if I call the script like myscript(this()) in a DTML-Document  I cannot
 > get the reference to this DTML-Document. So how do I get reference to a
 > DTML- or ZPT Document in script called from that Document ?
The easiest and safest method is to pass it explicitly.

Inside the DTML Document (say "doc"), you do not have the fully
acqisition wrapped object but only "doc.aq_explicit".
Therefore, access to your script by way of "this()" may fail.
If it would succeed, "this().script" would be the right way to go.


Dieter