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. _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users