[Zope3-checkins] CVS: Zope3/src/zope/app/services - event.py:1.1.2.2
Guido van Rossum
guido@python.org
Mon, 23 Dec 2002 17:57:44 -0500
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv27311
Modified Files:
Tag: NameGeddon-branch
event.py
Log Message:
Reordered.
=== Zope3/src/zope/app/services/event.py 1.1.2.1 => 1.1.2.2 === (501/601 lines abridged)
--- Zope3/src/zope/app/services/event.py:1.1.2.1 Mon Dec 23 14:32:22 2002
+++ Zope3/src/zope/app/services/event.py Mon Dec 23 17:57:44 2002
@@ -11,19 +11,149 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
-Revision information:
+"""Event service implementation.
+
$Id$
"""
+from persistence import Persistent
+
+from zope.app.component.nextservice import getNextService
+from zope.app.event.globaleventservice import eventService
+from zope.app.interfaces.services.event import IPathSubscriber
+from zope.app.interfaces.traversing.traverser import ITraverser
+from zope.app.traversing import getPhysicalPathString
+from zope.component import getAdapter
+from zope.component import getService
+from zope.event.subscribable import Subscribable
from zope.exceptions import NotFoundError
-from zope.interfaces.event import ISubscriptionAware
+from zope.interface import Attribute
from zope.interfaces.event import IEvent
+from zope.interfaces.event import IEventChannel
+from zope.interfaces.event import IEventService
+from zope.interfaces.event import ISubscriptionAware
+from zope.proxy.context.context import ContextWrapper
+from zope.proxy.context.context import isWrapper
from zope.proxy.context import ContextMethod
from zope.proxy.introspection import removeAllProxies
-from zope.proxy.context.context import ContextWrapper
from zope.app.component.nextservice import getNextService, queryNextService
+from zope.app.interfaces.services.service import IBindingAware
+from zope.app.traversing import getPhysicalPathString, traverse
+
+
+class LocalSubscribable(Persistent, Subscribable):
+ """a local mix-in"""
+
+ __implements__ = (
+ Subscribable.__implements__,
+ Persistent.__implements__)
+
+ # uses (and needs) __init__ from zope.event.subscribable
+
[-=- -=- -=- 501 lines omitted -=- -=- -=-]
- "mix-in for subscribers that want to know to whom they are subscribed"
-
- __implements__ = ISubscriptionAware
-
- def __init__(self):
- self._subscriptions = ()
-
- def subscribedTo(self, subscribable, event_type, filter):
- # This breaks for subscriptions to global event service.
- # Unless the global event service becomes persistent, this
- # is probably correct behavior.
- subscribable_path = getPhysicalPathString(subscribable)
- if (subscribable_path, event_type, filter) not in self._subscriptions:
- self._subscriptions += ((subscribable_path, event_type, filter),)
-
- def unsubscribedFrom(self, subscribable, event_type, filter):
- # global event service breaks, as above
- subscribable_path = getPhysicalPathString(subscribable)
- sub = list(self._subscriptions)
- sub.remove((subscribable_path, event_type, filter))
- self._subscriptions = tuple(sub)
-
-
-"""
-
-Revision information:
-$Id$
-"""
-
-from zope.component import getAdapter
-from zope.app.interfaces.traversing.traverser import ITraverser
-from zope.interfaces.event import ISubscriptionAware
-from zope.proxy.introspection import removeAllProxies
-from zope.app.interfaces.services.event import IPathSubscriber
-from zope.interface import Attribute
-from Zope.App.Traversing import getPhysicalPathString, traverse
-
-from zope.proxy.context import ContextMethod
-
class AbstractIndirectSubscriber:
def notify(wrapped_self, event):
@@ -633,6 +556,7 @@
subscribable, event_type, filter )
unsubscribedFrom=ContextMethod(unsubscribedFrom)
+
class PathSubscriber(AbstractIndirectSubscriber):