[Zope3-Users] Can't rename objects

Florian Lindner mailinglists at xgm.de
Wed Jan 17 15:24:41 EST 2007


Am Mittwoch, 17. Januar 2007 00:44 schrieb Marius Gedminas:
> On Tue, Jan 16, 2007 at 09:05:59PM +0100, Florian Lindner wrote:
> > I have a container object to which I can add and remove object but can
> > not rename them. I suspet my I namechooser to be faulty:
>
> That might be true.
>
> > from zope.app.container.interfaces import INameChooser
> > from zope.app.container.contained import NameChooser
> >
> > class XGMNameChooser(NameChooser):
> >     implements(INameChooser)
> >
> >     def chooseName(self, name, object):
> >         if IAbbreviation.providedBy(object):
> >             # my name choosing code
> >             return n
>
> I'm not sure I remember things correctly, but shouldn't your name
> chooser verify and optionally accept ``name`` here, if you want the
> user's desired name to ever be used?
>
> >         else:
> >             return super(XGMNameChooser, self).chooseName(name, object)
> >
> >
> > registered like that:
> >
> >     <adapter
> >         for=".interfaces.IXGM"
> >         provides="zope.app.container.interfaces.INameChooser"
> >         factory=".xgm.XGMNameChooser"
> >     />
> >
> >
> > furthermore the objects interface implements:
> >
> > IContainer, IContained, IPossibleSite, IAttributeAnnotatable,
> > IContainerNamesContainer.
>
> IContainerNamesContainer means "the user will *never* get to specify the
> names used for the elements stored in this container, instead the names
> will *always* be computed automatically by the name chooser."
>
> Remove this interface and you will get your "Rename" button in the ZMI.

Thanks, that does the trick.


More information about the Zope3-users mailing list