[Zope3-Users] Re: How to prevent several notifications of events ?

Florent Guillaume fg at nuxeo.com
Thu Jun 1 06:27:52 EDT 2006


Thierry FLORAC wrote:
> I've build a simple adapter that modifies context properties through
> annotations ; everything works fine.
> In several cases, when some attributes are updated, I do a
> "notify(ObjectModifiedEvent(self.context))" so that several subscribers
> are called.
> 
> My problem is then that if several attributes modifications are done,
> several "ObjectModifiedEvent" are sent and the same handler is called
> several times (with the same parameters) ; so is it easily possible to
> prevent the same event to be called several times for a same context and
> a same request ?
> Or should I try to use request annotations and subscribe to
> IEndRequestEvent (if it's not too late and not too expensive...) ?

Yes that's the proper way to do compress events: record the stuff to do, and 
do it at the end of the request.

Depending on the stuff to do, it may involve subtleties, for instance if you 
modify one object then delete it in the same request, you don't want to call 
your final handler for that object...

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope3-users mailing list