[Zope] Do-it-yourself acquisition -- is there an easier way?

Dieter Maurer dieter@handshake.de
Sat, 17 Aug 2002 11:39:20 +0200


VanL writes:
 > I have python products and python scripts in which I am trying to get a 
 > certain object, by id, from higher up in the acquisition chain.
 > 
 > I know that this object is in a folder named 'toolbox', so the code I 
 > have is as follows:
 > 
 >    def get_foo(self, fooID):
 >        default_foo = None
 >        for parentObj in self.aq_chain:
 >            try:
 >                toolbox = parentObj._getOb('toolbox')
 >                foo = toolbox._getOb(fooID)
 >                return foo
 >            except: continue
 >        return default_foo
 > 
 > This works, but seems very clunky.  Is there an API call that is 
 > cleaner?  Does the method above have a hidden danger or difficulty that 
 > I am not seeing?
Hell! Do you know "[un]restrictedTraverse"?


Dieter