[Zope-dev] Accessing parent object

Evan Simpson evan@digicool.com
Thu, 24 Feb 2000 07:38:59 -0600


----- Original Message -----
From: Robert Sander <gurubert@gurubert.de>
> class One(Implicit, Persistent, RoleManager, Folder):
>     attribute = "Some text or something else"
>     def somemethod(self):
>         ob = Two()
>         self._setObject("id", ob)
>         ob.method()
>
> class Two(Implicit, Persistent, RoleManager, Folder):
>     def method(self):
>         print self.aq_acquire("attribute")
>
> one = One()
> one.somemethod()
>
> Leads toward an AttributeError because aq_acquire was not found in
Two.method()

I'm afraid this isn't going to improve your opinion of the documentation
<wink>.  Your Two instance doesn't have aq_acquire because it's not in an
acquisition wrapper;  It would only get one by being acquired, or by
adding...

ob = ob.__of__(self)

...before the 'ob.method()' line.

Searching www.zope.org on Acquisition gets me quite a few documents,
including Jim Fulton's
http://www.zope.org/Members/jim/Info/IPC8/AqAlgNews
Admittedly, none of them seems to talk about the aq_* methods.  You don't
have to hit the C source, though; See lib/Components/ExtensionClass/*.stx
(docs in structured text).

Cheers,

Evan @ 4-am & digicool