[Zope-dev] Reg. persisting data in ZODB via forms

Charlie Clark charlie.clark at clark-consulting.eu
Wed Jun 8 04:48:37 EDT 2011


Hi Joshua,

Am 08.06.2011, 10:34 Uhr, schrieb Joshua Immanuel <josh at hipro.co.in>:

> Hello all,
> 	I am using zope.formlib.form package for my forms, when overriding the
> 'createAndAdd' method of form.AddForm I don't explicitly do the
> zope.event.notify(ObjectCreatedEvent(..)) call. I just add the data to
> self.context and it gets added (persisted) in the ZODB.

Persistence is handled by the transaction management and is IIRC  
independent of the notifications system. Nevertheless, not calling the  
events is not advisable.

> 	But when I extend the form.EditForm in order to implement my own
> "Apply" action method, just calling the form.applyData or
> form.applyChanges doesn't persist the data.
> zope.event.notify(ObjectModifiedEvent(..)) call is needed in order to
> persist data.

> 	If someone could explain on this or point me to some documentation
> relating to this would be very helpful to me.

 From memory I can recall something similar related to making changes to  
copies of instance attributes but failing to apply them to attributes and  
needing to specifically go context.attribute = form_result for the changes  
to persist.

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226


More information about the Zope-Dev mailing list