[Zope3-checkins] CVS: Zope3/src/zope/event - __init__.py:1.1.2.2 eventchannel.py:1.1.2.2 subscribable.py:1.1.2.2
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:36 -0500
Update of /cvs-repository/Zope3/src/zope/event
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/event
Modified Files:
Tag: NameGeddon-branch
__init__.py eventchannel.py subscribable.py
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py. The
files are fixed-points of that script now. Fixed a few cases where
code relied on significant trailing whitespace (ouch).
=== Zope3/src/zope/event/__init__.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/event/__init__.py:1.1.2.1 Mon Dec 23 14:32:48 2002
+++ Zope3/src/zope/event/__init__.py Tue Dec 24 21:21:03 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -50,4 +50,3 @@
if context is None: context=subscriber
return getEventService(context).listSubscriptions(
subscriber, event_type)
-
=== Zope3/src/zope/event/eventchannel.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/event/eventchannel.py:1.1.2.1 Mon Dec 23 14:32:48 2002
+++ Zope3/src/zope/event/eventchannel.py Tue Dec 24 21:21:03 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -21,18 +21,14 @@
from zope.interfaces.event import IEventChannel
class EventChannel(Subscribable):
-
+
__implements__ = IEventChannel
-
+
def notify(self, event):
-
+
for subscriptions in self.subscriptionsForEvent(event):
-
+
for subscriber, filter in subscriptions:
if filter is not None and not filter(event):
continue
subscriber.notify(event)
-
-
-
-
=== Zope3/src/zope/event/subscribable.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/event/subscribable.py:1.1.2.1 Mon Dec 23 14:32:48 2002
+++ Zope3/src/zope/event/subscribable.py Tue Dec 24 21:21:03 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -27,7 +27,7 @@
class Subscribable:
"""a global mix-in"""
-
+
__implements__ = ISubscribable
# plus has subscriptionsForEvent
@@ -35,18 +35,18 @@
self._registry = TypeRegistry()
self._subscribers = [] # using a list rather than a dict so
# that subscribers may define custom __eq__ methods
-
+
_clear = __init__
def subscribe(self, subscriber, event_type=IEvent, filter=None):
clean_subscriber = removeAllProxies(subscriber)
-
+
if ISubscriptionAware.isImplementedBy(subscriber):
subscriber.subscribedTo(self, event_type, filter)
-
+
if event_type is IEvent:
event_type = None # optimization
-
+
subscribers = self._registry.setdefault(event_type, [])
subscribers.append((clean_subscriber, filter))
@@ -58,12 +58,12 @@
self._subscribers.append((clean_subscriber, {event_type: 1}))
self._registry = self._registry #trigger persistence, if pertinent
-
-
+
+
def unsubscribe(self, subscriber, event_type=None, filter=None):
-
+
clean_subscriber=removeAllProxies(subscriber)
-
+
for subscriber_index in range(len(self._subscribers)):
sub=self._subscribers[subscriber_index]
if sub[0]==clean_subscriber:
@@ -73,10 +73,10 @@
if event_type: raise NotFoundError(subscriber)
else: return # this was a generic unsubscribe all request;
# work may have been done by a local service
-
-
+
+
do_alert=ISubscriptionAware.isImplementedBy(clean_subscriber)
-
+
if event_type:
ev_type=event_type
if event_type is IEvent:
@@ -86,7 +86,7 @@
subscriptions = self._registry.get(ev_type)
if not subscriptions:
raise NotFoundError(subscriber, event_type, filter)
- try:
+ try:
subscriptions.remove((clean_subscriber, filter))
except ValueError:
raise NotFoundError(subscriber, event_type, filter)
@@ -120,11 +120,11 @@
# used only for notify methods now. Could this be replaced
# with an explanatory comment in the code that uses it?
return self._registry.getAllForObject(event)
-
+
def listSubscriptions(self, subscriber, event_type=None):
-
+
subscriber=removeAllProxies(subscriber)
-
+
result=[]
if event_type:
ev_type=event_type