[Zope] object acquisition via python scripts

Paul Winkler pw_lists at slinkp.com
Fri Jul 22 11:21:28 EDT 2005


On Fri, Jul 22, 2005 at 04:10:03PM +0100, Jon Bowlas wrote:
> And my get_attobject script contains the following code:
> 
>  
> 
>       attobjects = context.objectValues('Attributes object')
> 
>       if attobjects:
> 
>             return attobjects[0]
> 
>       return None
> 
(snip)
> But what I'd like to do in this situation is use acquisition to retrieve the
> values from the parent 'Attributes object' located in the site root. So
> could someone please explain how I could achieve this?

As you've discovered, objectValues() does not use acquisition, it
only looks for real sub-objects of the folder you call it on.
Same is true for objectItems() and objectIds().

This kind of thing is typically done by always using the same id for
your "attributes object". Then just acquire that id.
In a sense, the id becomes part of your API.

Your script would become:
 
attrobject = getattr(context, 'some_id', None)
return attrobject

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list