Re: [Zope-dev] Events and interfaces for different request types
Hi Sidnei > Betreff: [Zope-dev] Events and interfaces for different request types > > 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... I personaly think the request which is almost only a user interaction should not be a part of the model. The basic event subscribers will act at the (MVC) model level independent of what user will interact and independent from the different user interfaces e.g. web browser web dav etc. But I see your point. I think what is missing is some kind of view events. Because the API which web dav uses is implemented as views, right? I also think this is probably special for FTP and Web Dav but not required in web browser views. Regards Roger Ineichen _ END OF MESSAGE > -- > Sidnei da Silva > Enfold Systems http://enfoldsystems.com > Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 > ___ > 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 ) > ___ 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 )
Re: [Zope-dev] Events and interfaces for different request types
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 )
Re: [Zope-dev] Events and interfaces for different request types
On Wednesday 10 September 2008, Robert Marianski wrote: > And you should be able to register event handlers for the 3 channels now. Of course that works. :-) It's just a multi-adapter lookup. ;-) Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. "Zope Stephan Richter" ___ 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 )