[Zope] context in a Product's python code (not Python Script)
John K. Hohm
jhohm@acm.org
Tue, 3 Dec 2002 21:05:46 -0600
Quoting Dieter Maurer <dieter@handshake.de>:
> John K. Hohm writes:
> > I have a Page Template and Python Script that are working fairly well
> > together to generate a navigational menu on my site, and now I want to
> > make them part of a product. I have tried this:
>
> The "context" equivalent in a Python product's method
> is usually "self.aq_parent"; the "container" equivalent
> "self.aq_inner.aq_parent".
I expected you to be right, so I tried a simple method like this:
security.declarePublic('foo')
def foo(self):
"""Test method"""
return self.aq_parent.absolute_url()
When called through the web, it displays the URL for the parent of the instance
that defines foo, not the object on which I'm calling the method. Aargh!