[Zope3-Users] How to prevent several notifications of events ?
Thierry FLORAC
tflorac at ulthar.net
Thu Jun 1 17:48:58 EDT 2006
On Thu, 2006-06-01 at 12:27 +0200, Florent Guillaume wrote:
> 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...
Thanks for the reply, but I'd like to have a few complements :
- I suppose that IEndRequestEvent is sent automatically for every
request, so even for consultation requests which doesn't imply any
modification. So I suppose that the IEndRequestEvent handler have to be
VERY optimised if I don't want it to be too expensive.
- what is the best way to keep track of objects having been modified
(and which, for example, should be re-indexed) into request annotations.
Can I just put an object into an annotation's list (with a kind of
"IAnnotations(request)['myKey'].append(context)") ??
Thanks,
Thierry
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20060601/f17a31b3/attachment.htm
More information about the Zope3-users
mailing list