[Zope3-Users] Can't rename objects

Marius Gedminas mgedmin at b4net.lt
Tue Jan 16 18:44:16 EST 2007


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.

> the class itself:
> 
> BTreeContainer, SiteManagerContainer
> 
> What's wrong?

Marius Gedminas
-- 
If you are angry with someone, you should walk a mile in their shoes... then
you'll be a mile away from them, and you'll have their shoes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20070117/b8780732/attachment.bin


More information about the Zope3-users mailing list