Hello all, 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??? I think I understand the reason you get FolderA1s title attribute because it is the container of DTML_Doc and thus is the aq_parent of CommonStuff in the namespace. But, then how does one pull attributes such as the title from the caller which in this case is a DTML_Doc? How does one get a handle on the object that called a script? Any ideas? -Chris ------------------------------ Chris Kratz chris.kratz@vistashare.com
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
Thanks for the response Dieter,
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).
Hmmm, so the short answer is, you can't. My continued experimentation has indeed shown this to be true. It appears that the only way to get the information is to create a new property (ie page_title) that would then show up in the namespace (because it isn't replaced by any of the properties in CommonStuff), pass it in via a parameter, or use the properties of the containing folder. I don't particularly like any of the options, but I think I will go with the last one for now. Thanks for the help, -Chris ------------------------------ Chris Kratz chris.kratz@vistashare.com ----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: "Chris Kratz" <chris.kratz@vistashare.com> Cc: <zope@zope.org> Sent: Friday, November 30, 2001 4:30 PM Subject: Re: [Zope] DTML Doc and Python scripts and aq_parent
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
participants (2)
-
Chris Kratz -
Dieter Maurer