[Zope3-Users] Re: object id / name / name within parent?

Florent Guillaume fg at nuxeo.com
Mon Jan 10 08:22:23 EST 2005


Philipp von Weitershausen  <philipp at weitershausen.de> wrote:
> Florent Guillaume wrote:
> > Petri Savolainen  <petri.savolainen at iki.fi> wrote:
> > 
> >>Wow I've got a real newbie question here: How does the identification 
> >>and naming of objects work in Zope3?
> >>
> >>I understand that objects have names, stored in the __name__ attribute 
> >>of an object, and that this 'name' is what containers know contained 
> >>objects by. To what extent is this analogous to a Zope2 id? Or do Z3 
> >>objects have an id, in addition to name?
> > 
> > The name is indeed comparable to Zope 2's id. Except that in Zope 2,
> > both an object and its container know the id (which makes for redundant
> > information that can get out of sync etc), whereas in Zope 3 the name is
> > only stored with the object itself.
> 
> Wrong. The container keeps the name, too. Containers are usually simple 
> mapping objects (like a dict). The fact that the name is also stored on 
> the object is an extra feature that you really shouldn't know about 

Ok sorry for the confusion. I was actually mixing up container/object
here, mistake further compounded by other stuff. I remember that
initially in Z3 only the container stored the name. Then optimizations
kicked in, and the model for object reference changed a bit I guess.

Florent

> because you should use
> 
>    >>> zapi.getName(obj)
> 
> anyways. That will adapt 'obj' to IPhysicallyLocatable and extract its 
> name from wherever the implementation wants to get it from. For most 
> persistent objects (or contained proxied ones), this is __name__. It 
> doesn't have to be, though.
> 
> For retrieving and manipulating contained information (name and 
> parents), one should preferrably use the provided machinery, meaning the 
> zapi methods (getName, getParent, getParents, etc.) and the 
> contained/setitem functions from zope.app.container.contained.
> 
> Philipp
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 


-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope3-users mailing list