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.

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to