[Zope3-Users] NameChooser functionality for
IContainerNamesContainer
Tom Dossis
td at yoma.com.au
Mon Jan 16 15:47:56 EST 2006
Joel Moxley wrote:
> I successfully added a name chooser for objects added through an add
> form to my container. This involved implementing
> IContainerNamesContainer on my container, INameChooser on my
> NameChooser, registering each, and being sure to set my set_before_add
> fields in the addform registration.
>
> What is The Right Way (tm) to use this NameChooser functionality
> outside of the addform? In other words, I have a method that defines
> the container from a file as follows:
>
> self[name] = obj
>
> This obviously would overwrite duplicates, etc. I would prefer to
> have something as follows which would use the NameChooser machinery
> automatically (ie, without having to get the NameChooser adapter in my
> method). Is there a way I can do something along the lines of this?
>
> self.add(obj)
>
Maybe something like:
class MyContainer..
..
def add(obj, name=''):
name = INameChooser.chooseName(name, obj)
self[name] = obj
..
More information about the Zope3-users
mailing list