[Zope] DTML Doc and Python scripts and aq_parent

Dieter Maurer dieter@handshake.de
Fri, 30 Nov 2001 22:30:48 +0100


Chris Kratz writes:
 > I'm trying to wrap my head around acquisition once again.  Each time I think
 > I get it, another curve ball gets me.  If anyone has any pointers I would
 > appreciate it.
 > 
 > I have the following structure:
 > 
 > Root
 >  + FolderA
 >      + Folder A1
 >           DTML_Doc w "Really Nifty Title"
 >   + CommonStuff
 >       + PythonScript
 > 
 > inside of DTML_Doc, there are several lines of code that look something like
 > this:
 > 
 > <dtml-with CommonStuff>
 >   <dtml-var PythonScript>
 > </dtml-with>
 > 
 > In the python script I have the following
 > 
 > print context.title                                 # Prints 'PythonScript'
 > print context.aq_parent.title                 # Prints 'CommonStuff'
 > print context.aq_parent.aq_parent.title #  Prints Folder A1  ???Huh???

You know Shane's "show_aq" External Method? It provides for a visual
representation (ASCII art!) of the acquisition structure and is
a valuable aid in understanding acquisition.

In your case, the reason almost surely is, that "DTML Document" tries
to prevent acquisition through itself (it pushes "self.aq_explicit"
and not "self" onto the namespace). This usually means, that objects
are not found via the DTML Document but (as for DTML Methods) via
the client. Exceptions are the DTML Documents own attributes
and when "aq_explict" does not do what it is "supposed" to do
(--> mailing list archives; problem report from me).


Dieter