[Zope-dev] Events and interfaces for different request types

Sidnei da Silva sidnei at enfoldsystems.com
Wed Sep 10 16:25:20 EDT 2008


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


More information about the Zope-Dev mailing list