[Zope-PTK] Access "top" object without passing it as argumentto
method?
Shane Hathaway
shane@digicool.com
Wed, 28 Feb 2001 09:58:24 -0500
Sigve Tjora wrote:
>
> > Are you looking for "this()"? If you added a parameter to the method,
> > you could call:
> >
> > <dtml-var "portal_yourtool.yourMethod(this())">
> >
> > Shane
>
> I am looking for "this()", but I don't want to pass it explicit as an
> argument to the method. I want to use what "this()" refers to without
> having to pass it on as an argument to my method. Is this possible?
Reliably, no. This will *usually* give what you want:
def mymethod(self):
caller = self.aq_parent.aq_parent
But you'll notice that the CMF already uses the pattern I mentioned
before. It is reliable and correct, though you may have to perform your
own security checks.
Shane