On Wed, Sep 10, 2008 at 06:25:20PM -0200, Sidnei da Silva wrote: > Hi all, > > More than once I've found myself on a situation where I needed to > subscribe to a specific event but only if it happens through a > specific request type. One problem with that is that commonly the > request is not part of the event information. Another problem might be > that the request type might not be properly flagged, but this is a > different subject and applies mostly to Zope 2. > > Now, for solving this problem, I usually create a custom and more > specialized event that includes the request as part of it's > information. So, for example, I'm interested in IObjectModifiedEvent > but only for IWebDAVRequest, then I create: > > class IObjectRequestModifiedEvent(IObjectModifiedEvent): > request = Attribute(...) > > def subscriber(object, event): > if IWebDAVRequest.isProvidedBy(event.request): > # do something > > Now, I wonder if someone has any suggestion on how to simplify this further... > -- > Sidnei da Silva > Enfold Systems http://enfoldsystems.com > Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
I haven't tried this, but you might be able to send out an event on an additional channel in a general handler. Something like: def subscriber(object, event): notify(object, event, event.request) And you should be able to register event handlers for the 3 channels now. -- Robert
pgputeu7jhKg3.pgp
Description: PGP signature
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )