zope acquistion

J

John Hunter

I know this post is better on the zope mailing list (in fact I posted
it there). But for some reason my posts there are being help for days
before getting through and I'm hopeful the good folks on this list
will have an answer for me!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top