[Zope-CVS] CVS: Products/Event - EventService.py:1.2 IEventService.py:1.2

Chris McDonough chrism@zope.com
Sun, 30 Jun 2002 02:35:05 -0400

Update of /cvs-repository/Products/Event
In directory cvs.zope.org:/tmp/cvs-serv22481

Modified Files:
	EventService.py IEventService.py 
Log Message:
When "notify" was called on a subscriber, the subscriber had no
context.  Now, the context is the event service (by default), or
a context specified via the context argument to publishEvent.

=== Products/Event/EventService.py => 1.2 ===
     security.declareProtected(PUBLISH_EVENTS_PERM, 'publishEvent')
-    def publishEvent(self, event):
+    def publishEvent(self, event, context=None):
+        # we need a context for the subscriber.  If one
+        # is not passed in, we nominate ourselves as the context.
+        if context is None:
+            context = self 
         subscriptions_collection = self._registry.getAllForObject(event)
         for subscriptions in subscriptions_collection:
@@ -63,6 +67,7 @@
                 if filter is not None:
                     if not filter(event):
+                subscriber = subscriber.__of__(context)
     security.declareProtected(MGMT_SCREEN_PERM, 'listAllSubscriptions')

=== Products/Event/IEventService.py => 1.2 ===
-    def publishEvent(event):
+    def publishEvent(event, context=None):
         Notify all subscribers of the channel of event.
         Events will often be propagated to higher level IEventServices;
         This is a policy decision for the IEventService.
+        If context is passed in, it is used for a subscriber's
+        context when the subscriber is notified.  If context
+        is not passed in, the subscriber's context will be
+        the event service object itself during notification.