[Zope-Checkins] CVS: Zope3/lib/python/Zope/Event - Subscribable.py:1.1.2.2

Gary Poster garyposter@earthlink.net
Fri, 17 May 2002 23:32:50 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Event
In directory cvs.zope.org:/tmp/cvs-serv19452/lib/python/Zope/Event

Modified Files:
      Tag: Zope-3x-branch
	Subscribable.py 
Log Message:
Some tests of the changes in the global event service, and a small fix that one of them found.  Tests of the local event service later...



=== Zope3/lib/python/Zope/Event/Subscribable.py 1.1.2.1 => 1.1.2.2 ===
                 raise NotFoundError(subscriber, event_type, filter)
             subscriptions = self._registry.getJustForType(ev_type)
-            try:
+            if not subscriptions:
+                raise NotFoundError(subscriber, event_type, filter)
+            try: 
                 subscriptions.remove((clean_subscriber, filter))
             except ValueError:
                 raise NotFoundError(subscriber, event_type, filter)
@@ -125,9 +127,10 @@
             if event_type is IEvent:
                 ev_type=None # handle optimization
             subscriptions = self._registry.getJustForType(ev_type)
-            for sub in subscriptions:
-                if sub[0]==subscriber:
-                    result.append((event_type, sub[1]))
+            if subscriptions:
+                for sub in subscriptions:
+                    if sub[0]==subscriber:
+                        result.append((event_type, sub[1]))
         else:
             for subscriber_index in range(len(self._subscribers)):
                 sub=self._subscribers[subscriber_index]
@@ -138,7 +141,8 @@
                 return result
             for ev_type in ev_set:
                 subscriptions = self._registry.getJustForType(ev_type)
-                for sub in subscriptions:
-                    if sub[0]==subscriber:
-                        result.append((ev_type or IEvent, sub[1]))
+                if subscriptions:
+                    for sub in subscriptions:
+                        if sub[0]==subscriber:
+                            result.append((ev_type or IEvent, sub[1]))
         return result