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

Tom Dossis td at yoma.com.au
Mon Jan 10 07:18:57 EST 2005


Florent Guillaume wrote:
> > 
> 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.

I need to spell that out for myself...

 >>> f = Folder()
 >>> list(f)
[]
 >>> sub = Folder()
 >>> sub.__name__ is sub.__parent__ is None
True

 >>> f['myid'] = sub
 >>> sub.__name__
u'myid'
 >>> sub.__parent__ is f
True


So the container sets the name of the object.

IWriteContainer
   ...
   __setitem__(name, object)
    """Add the given object to the container under the given name.
	...
       The object's __parent__ and __name__ attributes are set
       to the container and the given name.
         ...



More information about the Zope3-users mailing list