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

Chris Withers chrisw@nipltd.com
Fri, 16 Aug 2002 10:45:12 +0100


VanL wrote:
> Hello,
> 
> 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

urm, does the following code do the same as the above?

def get_foo(self,fooID):
    return getattr(self.toolbox,fooID,None)

cheers,

Chris