[Zope] problem with acquisition
John Hunter
jdhunter at ace.bsd.uchicago.edu
Fri Jun 18 10:27:48 EDT 2004
I have a zope containment hierarchy
base/somefolder/myobj
base/other
base, somefolder, myobj, and other are all instances of a MyFolder
class which is derived from Folder. MyFolder is a simple extension of
Folder that limits the allowed meta classes.
I would like to acquire the 'other' folder from a myobj instance using
the python API. Ie, I have a class method in which I need to be able
to do
def somemethod(self, someinstance):
otherFolder = acquisition_magic(someinstance, 'other')
where I know someinstance is a MyFolder instance which is either base
itself, is contained in base (possibly deep in the tree). Ie, I would
like this method to work if someinstance is one of base, somefolder,
or myobj.
Since all of these instances derive from Acquisition.Implicit via
ObjectManager, I think I should be able to do this.
I thought from Acquisition import aq_get, aq_acquire, aq_parent
def somemethod(self, someinstance):
folder = aq_acquire(someinstance, 'other')
would do it for me, but this raises an AttributeError when passed a
myobj instance.
Thanks!
JDH
zope 2.7
More information about the Zope
mailing list