[Zope3-checkins] CVS: Zope3/lib/python/Zope/Event - EventChannel.py:1.3 GlobalEventService.py:1.3 Subscribable.py:1.3
Jim Fulton
jim@zope.com
Thu, 1 Aug 2002 11:33:45 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Event
In directory cvs.zope.org:/tmp/cvs-serv4877/lib/python/Zope/Event
Modified Files:
EventChannel.py GlobalEventService.py Subscribable.py
Log Message:
Refactored and moved Zope.ComponentArchitecture.IToIRegistry into
Interface.Registry. This is only the first step. The tests pass and
Zope 3 runs, but there are a bunch of wrong dependencies that still
need to get cleaned up, which is my next task.
=== Zope3/lib/python/Zope/Event/EventChannel.py 1.2 => 1.3 ===
def notify(self, event):
- subscriptionses = self._registry.getAllForObject(event)
-
- for subscriptions in subscriptionses:
+ for subscriptions in self.subscriptionsForEvent(event):
- for subscriber,filter in subscriptions:
+ for subscriber, filter in subscriptions:
if filter is not None and not filter(event):
continue
subscriber.notify(event)
=== Zope3/lib/python/Zope/Event/GlobalEventService.py 1.2 => 1.3 ===
def publishEvent(self, event):
- subscriptionses = self._registry.getAllForObject(event)
-
- for subscriptions in subscriptionses:
+ for subscriptions in self.subscriptionsForEvent(event):
- for subscriber,filter in subscriptions:
+ for subscriber, filter in subscriptions:
if filter is not None and not filter(event):
continue
subscriber.notify(event)
=== Zope3/lib/python/Zope/Event/Subscribable.py 1.2 => 1.3 ===
$Id$
"""
-from Zope.ComponentArchitecture.IToIRegistry import TypeRegistry
+from Interface.Registry.TypeRegistry import TypeRegistry
from Zope.Exceptions import NotFoundError
from ISubscribable import ISubscribable
from ISubscriptionAware import ISubscriptionAware
@@ -46,7 +46,7 @@
ev_type=event_type
if ev_type is IEvent: ev_type=None # optimization
- subscribers = self._registry.getJustForType(ev_type)
+ subscribers = self._registry.get(ev_type)
if subscribers is None:
subscribers = []
self._registry.register(ev_type, subscribers)
@@ -86,7 +86,7 @@
ev_type=None # handle optimization
if ev_type not in ev_set:
raise NotFoundError(subscriber, event_type, filter)
- subscriptions = self._registry.getJustForType(ev_type)
+ subscriptions = self._registry.get(ev_type)
if not subscriptions:
raise NotFoundError(subscriber, event_type, filter)
try:
@@ -103,7 +103,7 @@
del self._subscribers[subscriber_index]
else:
for ev_type in ev_set:
- subscriptions = self._registry.getJustForType(ev_type)
+ subscriptions = self._registry.get(ev_type)
subs=subscriptions[:]
subscriptions[:] = []
for sub in subs:
@@ -116,6 +116,9 @@
subscriptions.append(sub)
del self._subscribers[subscriber_index]
self._registry=self._registry #trigger persistence, if pertinent
+
+ def subscriptionsForEvent(self, event):
+ return self._registry.getAllForObject(event)
def listSubscriptions(self, subscriber, event_type=None):
@@ -126,7 +129,7 @@
ev_type=event_type
if event_type is IEvent:
ev_type=None # handle optimization
- subscriptions = self._registry.getJustForType(ev_type)
+ subscriptions = self._registry.get(ev_type)
if subscriptions:
for sub in subscriptions:
if sub[0]==subscriber:
@@ -140,9 +143,9 @@
else:
return result
for ev_type in ev_set:
- subscriptions = self._registry.getJustForType(ev_type)
+ subscriptions = self._registry.get(ev_type)
if subscriptions:
for sub in subscriptions:
if sub[0]==subscriber:
result.append((ev_type or IEvent, sub[1]))
- return result
\ No newline at end of file
+ return result