On Wednesday 29 November 2006 14:02, David Johnson wrote:
> I am creating a custom content container and am getting the intricacies of
> the addform browser zcml directive. When I add an object in the ZMI to my
> custom container I notice that the __setitem__() method is called after I
> hit "Add" button. I also see how the set_before_add and set_after_add
> options are used.
First things first: Do not use the addform and editform directive. Pretty much
everyone is using zope.formlib.
> I notice that when the container's __setitem__ method is called with the
> new object, the attributes are not set. When do the attributes get set?
set_before_add's fields are set after instantiation (__init__ call).
After this the ObjectCreatedEvent should be sent out.
set_after_add's fields are set after the object has been added to the
After this the ObjectAddedEvent is sent out.
> However, how is custom handling done in addform? I could specify all the
> fields in the "set_before_add" option, but this is tedious and does not
> work well if the schema changes (because I have to remember to update the
> ZCML as well).
This is the reason you should use zope.formlib. ;-)
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-users mailing list