[Zope3-dev] how may __setitem__ choose name for a new item?

Jim Fulton jim at zope.com
Sat Dec 27 08:45:34 EST 2003


Marcus J. Ertl wrote:
> Hi everyone!
> 
> Which is the right way, to let a container choose, witch name a new item
> should have, witch is added to it?
>
 > Use __setitem__ and ignore the name given to it?

No.

Have the container provide the marker interface,
IContainerNamesContainer, which signals that the container
always picks a name.

To conteol how the name is chosen, implement or provide an
adapter to INameChooser.  There is a default adapter to
INameChooser that picks names for objects based on their class
names.

Note also that, as of the Bangalore sprint, the name chooser
will be used when the user doesn't pick a name.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list