[Zope3-Users] Re: __name__ in auto generated addforms

Philipp von Weitershausen philipp at weitershausen.de
Mon May 30 16:00:29 EDT 2005


Florian Lindner wrote:
> Hello,
> is it possible to let the user enter the name of a object (the __name__ 
> attribut) in forms that are auto generated from schema data (via the addform 
> directive)?

Florian, this is a question about using Zope 3, so please continue this 
discussion on zope3-users (I'm cc-ing zope3-users).

Now for your problem:

* Containers manage the names of objects, not the objects themselves

*  __name__ is just a convention of the location/contained machinery.

* Container name choosers can choose names for your object when you 
*add* it to the container. Name choosers don't play a role in edit 
forms. If you would like an example of a Name Chooser adapter, please 
refer to the examples in my book (they're downloadable on worldcookery.com).

* If you want to rename the object from within an edit form, you want to 
introduce a second schema that looks just like the object's schema but 
has an additional __name__ field (TextLine() with the appropriate 
constraints regarding special characters like '/' etc.). In an adapter 
from that schema to your actual schema you can do the renaming according 
to changes of __name__. Note that the form redirects the browser to 
itself (I think) which won't work anymore.

Philipp


More information about the Zope3-users mailing list