[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/LocalEventService - IPathSubscriber.py:1.4 LocalEventChannel.py:1.6 LocalEventService.py:1.7 LocalServiceSubscribable.py:1.7 LocalSubscriptionAware.py:1.5 ProtoServiceEventChannel.py:1.3
Steve Alexander
steve@cat-box.net
Mon, 11 Nov 2002 03:38:36 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/LocalEventService
In directory cvs.zope.org:/tmp/cvs-serv12489
Modified Files:
IPathSubscriber.py LocalEventChannel.py LocalEventService.py
LocalServiceSubscribable.py LocalSubscriptionAware.py
ProtoServiceEventChannel.py
Log Message:
reformatted code to be closer to z3 style.
Removed extraneous imports.
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/IPathSubscriber.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/IPathSubscriber.py:1.3 Mon Oct 21 02:14:45 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/IPathSubscriber.py Mon Nov 11 03:38:36 2002
@@ -19,7 +19,6 @@
from Interface.Attribute import Attribute
from Zope.Event.ISubscriber import IIndirectSubscriber
-
class IPathSubscriber(IIndirectSubscriber):
def __init__(wrapped_subscriber):
@@ -27,4 +26,4 @@
subscriber_path = Attribute(
"""the slash-delineated physical path to the subscriber"""
- )
\ No newline at end of file
+ )
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventChannel.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventChannel.py:1.5 Thu Nov 7 20:33:08 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventChannel.py Mon Nov 11 03:38:36 2002
@@ -31,21 +31,15 @@
# LocalSubscribable)!!
def notify(wrapped_self, event):
- clean_self=removeAllProxies(wrapped_self)
+ clean_self = removeAllProxies(wrapped_self)
subscriptionses = clean_self.subscriptionsForEvent(event)
# that's a non-interface shortcut for
# subscriptionses = clean_self._registry.getAllForObject(event)
for subscriptions in subscriptionses:
-
for subscriber,filter in subscriptions:
if filter is not None and not filter(event):
continue
ContextWrapper(subscriber, wrapped_self).notify(event)
-
- notify=ContextMethod(notify)
-
-
-
-
+ notify = ContextMethod(notify)
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventService.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventService.py:1.6 Mon Oct 21 02:14:46 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventService.py Mon Nov 11 03:38:36 2002
@@ -53,64 +53,60 @@
def publishEvent(wrapped_self, event):
"see IEventService"
- clean_self=removeAllProxies(wrapped_self)
+ clean_self = removeAllProxies(wrapped_self)
subscriptionses = clean_self._registry.getAllForObject(event)
for subscriptions in subscriptionses:
-
for subscriber,filter in subscriptions:
if filter is not None and not filter(event):
continue
ContextWrapper(subscriber, wrapped_self).notify(event)
- publishedEvents=getattr(clean_self, "_v_publishedEvents", None)
+
+ publishedEvents = getattr(clean_self, "_v_publishedEvents", None)
if publishedEvents is None:
- publishedEvents=clean_self._v_publishedEvents=[event]
- else: publishedEvents.append(event)
+ publishedEvents = clean_self._v_publishedEvents=[event]
+ else:
+ publishedEvents.append(event)
if(clean_self.isPromotableEvent(event)):
getNextService(wrapped_self, 'Events').publishEvent(event)
publishedEvents.remove(event)
-
- publishEvent=ContextMethod(publishEvent)
+ publishEvent = ContextMethod(publishEvent)
def notify(wrapped_self, event):
"see ISubscriber"
- clean_self=removeAllProxies(wrapped_self)
- publishedEvents=getattr(clean_self, "_v_publishedEvents", None)
+ clean_self = removeAllProxies(wrapped_self)
+ publishedEvents = getattr(clean_self, "_v_publishedEvents", None)
if publishedEvents is None or event not in publishedEvents:
-
subscriptionses = clean_self._registry.getAllForObject(event)
for subscriptions in subscriptionses:
-
for subscriber,filter in subscriptions:
if filter is not None and not filter(event):
continue
ContextWrapper(subscriber, wrapped_self).notify(event)
-
- notify=ContextMethod(notify)
+ notify = ContextMethod(notify)
def bound(wrapped_self, name):
"see IBindingAware"
- clean_self=removeAllProxies(wrapped_self)
+ clean_self = removeAllProxies(wrapped_self)
clean_self._serviceName = name # for LocalServiceSubscribable
if clean_self.subscribeOnBind:
- es=getNextService(wrapped_self, "Events")
+ es = getNextService(wrapped_self, "Events")
if es is not eventService:
# XXX if we really want to receive events from the
# global event service we're going to have to
# set something special up--something that subscribes
# every startup...
es.subscribe(PathSubscriber(wrapped_self))
-
- bound=ContextMethod(bound)
+ bound = ContextMethod(bound)
# _unbound = ProtoServiceEventChannel.unbound # see comment below
def unbound(wrapped_self, name):
"see IBindingAware"
- clean_self=removeAllProxies(wrapped_self)
- clean_self._v_unbinding=1
+ clean_self = removeAllProxies(wrapped_self)
+ clean_self._v_unbinding = 1
# this flag is used by the unsubscribedFrom method (below) to
# determine that it doesn't need to further unsubscribe beyond
# what we're already doing.
@@ -120,9 +116,9 @@
# but in actuality we're doing a copy and paste because of
# various wrapper/security problems:
# start copy/paste
- subscriber=PathSubscriber(wrapped_self)
+ subscriber = PathSubscriber(wrapped_self)
for subscription in clean_self._subscriptions:
- subscribable=getAdapter(
+ subscribable = getAdapter(
wrapped_self, ITraverser).traverse(subscription[0])
subscribable.unsubscribe(subscriber)
clean_self._subscriptions = ()
@@ -132,25 +128,23 @@
for subscriber in clean_self._subscribers:
clean_self.__unsubscribeAllFromSelf(wrapped_self, subscriber[0])
# unset flag
- clean_self._v_unbinding=None
-
- unbound=ContextMethod(unbound)
+ clean_self._v_unbinding = None
+ unbound = ContextMethod(unbound)
def __unsubscribeAllFromSelf(clean_self, wrapped_self, subscriber):
"""this is *not* an interface function, and should not be used
outside of this class"""
-
- wrapped_subscriber=ContextWrapper(subscriber, wrapped_self)
+ wrapped_subscriber = ContextWrapper(subscriber, wrapped_self)
for subscriber_index in range(len(clean_self._subscribers)):
- sub=clean_self._subscribers[subscriber_index]
- if sub[0]==subscriber:
- ev_set=sub[1]
+ sub = clean_self._subscribers[subscriber_index]
+ if sub[0] == subscriber:
+ ev_set = sub[1]
break
else:
raise NotFoundError(subscriber)
clean_self._p_changed = 1 # trigger persistence before change
- do_alert=ISubscriptionAware.isImplementedBy(subscriber)
+ do_alert = ISubscriptionAware.isImplementedBy(subscriber)
for ev_type in ev_set:
subscriptions = clean_self._registry.get(ev_type)
subs=subscriptions[:]
@@ -167,7 +161,7 @@
def unsubscribedFrom(wrapped_self, subscribable, event_type, filter):
"see ISubscriptionAware"
- clean_self=removeAllProxies(wrapped_self)
+ clean_self = removeAllProxies(wrapped_self)
if getattr(clean_self, "_v_unbinding", None) is None:
# we presumably have been unsubscribed from a higher-level
# event service because that event service is unbinding
@@ -176,21 +170,21 @@
# service to which to attach
ProtoServiceEventChannel.unsubscribedFrom(
clean_self, subscribable, event_type, filter)
- clean_subscribable=removeAllProxies(subscribable)
- if IEventService.isImplementedBy(removeAllProxies(clean_subscribable)):
- context=getService(wrapped_self, "Events")
+ clean_subscribable = removeAllProxies(subscribable)
+ if IEventService.isImplementedBy(
+ removeAllProxies(clean_subscribable)):
+ context = getService(wrapped_self, "Events")
# we do this instead of getNextService because the order
# of unbinding and notification of unbinding is not
# guaranteed
while removeAllProxies(context) in (
clean_subscribable, clean_self):
- context=getNextService(context, "Events")
+ context = getNextService(context, "Events")
# XXX as usual, we *must not* be working with a global service;
# this probably should raise an error if service is global
# service...
# that leaves replacing top level event services an
# interesting question, however
context.subscribe(PathSubscriber(wrapped_self))
-
- unsubscribedFrom=ContextMethod(unsubscribedFrom)
+ unsubscribedFrom = ContextMethod(unsubscribedFrom)
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalServiceSubscribable.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalServiceSubscribable.py:1.6 Mon Oct 21 02:14:46 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalServiceSubscribable.py Mon Nov 11 03:38:36 2002
@@ -12,7 +12,6 @@
#
##############################################################################
"""
-
Revision information:
$Id$
"""
@@ -32,15 +31,15 @@
__implements__ = LocalSubscribable.__implements__
_serviceName = None # should be replaced; usually done in "bound"
- # method of a subclass
+ # method of a subclass
# uses (and needs) __init__ from Zope.Event.Subscribable (via
# LocalSubscribable)
def unsubscribe(wrapped_self,
subscriber,
- event_type = None,
- filter = None):
+ event_type=None,
+ filter=None):
# might be wrapped, might not
subscriber = removeAllProxies(subscriber)
@@ -73,7 +72,7 @@
if ev_type not in ev_set:
getNextService(
wrapped_self, clean_self._serviceName).unsubscribe(
- subscriber, event_type, filter)
+ subscriber, event_type, filter)
else:
subscriptions = clean_self._registry.get(ev_type)
try:
@@ -110,12 +109,11 @@
wrapped_self, clean_self._serviceName).unsubscribe(
subscriber, event_type, filter)
clean_self._p_changed = 1 #trigger persistence
-
unsubscribe = ContextMethod(unsubscribe)
- def listSubscriptions(wrapped_self, subscriber, event_type = None):
+ def listSubscriptions(wrapped_self, subscriber, event_type=None):
# might be wrapped, might not
- subscriber = removeAllProxies(subscriber)
+ subscriber = removeAllProxies(subscriber)
clean_self = removeAllProxies(wrapped_self)
result = LocalSubscribable.listSubscriptions(
@@ -124,5 +122,4 @@
wrapped_self, clean_self._serviceName).listSubscriptions(
subscriber, event_type))
return result
-
listSubscriptions = ContextMethod(listSubscriptions)
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscriptionAware.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscriptionAware.py:1.4 Mon Oct 21 02:14:46 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscriptionAware.py Mon Nov 11 03:38:36 2002
@@ -20,14 +20,13 @@
from Zope.Event.ISubscriptionAware import ISubscriptionAware
from Zope.App.Traversing import getPhysicalPathString
-
class LocalSubscriptionAware:
"mix-in for subscribers that want to know to whom they are subscribed"
- __implements__=ISubscriptionAware
+ __implements__ = ISubscriptionAware
def __init__(self):
- self._subscriptions=()
+ self._subscriptions = ()
def subscribedTo(self, subscribable, event_type, filter):
# This breaks for subscriptions to global event service.
@@ -35,14 +34,11 @@
# 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),)
+ 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 = list(self._subscriptions)
sub.remove((subscribable_path, event_type, filter))
- self._subscriptions=tuple(sub)
-
-
-
+ self._subscriptions = tuple(sub)
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/ProtoServiceEventChannel.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/ProtoServiceEventChannel.py:1.2 Thu Nov 7 20:33:08 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/ProtoServiceEventChannel.py Mon Nov 11 03:38:36 2002
@@ -19,18 +19,13 @@
"""
from Zope.App.Traversing.ITraverser import ITraverser
-from Zope.Event.GlobalEventService import eventService
-from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.Proxy.ProxyIntrospection import removeAllProxies
from Zope.ComponentArchitecture import getAdapter, getService
from PathSubscriber import PathSubscriber
from LocalSubscriptionAware import LocalSubscriptionAware
from Zope.ContextWrapper import ContextMethod
-from Zope.App.ComponentArchitecture.NextService import getNextService
from LocalEventChannel import LocalEventChannel
from LocalServiceSubscribable import LocalServiceSubscribable
-from Interface.Attribute import Attribute
-from Zope.Event.IEventChannel import IEventChannel
from Zope.App.OFS.Services.ServiceManager.IBindingAware import IBindingAware
from Zope.Proxy.ContextWrapper import isWrapper
from Zope.Event.IEvent import IEvent
@@ -70,34 +65,33 @@
def bound(wrapped_self, name):
"see IBindingAware"
- clean_self=removeAllProxies(wrapped_self)
+ clean_self = removeAllProxies(wrapped_self)
clean_self._serviceName = name # for LocalServiceSubscribable
if clean_self.subscribeOnBind:
- es=getService(
- wrapped_self,
- clean_self._subscribeToServiceName)
+ es = getService(wrapped_self, clean_self._subscribeToServiceName)
if isWrapper(es):
# if we really want to receive events from a
# global event-type service we're going to have to
- # set something special up--something that subscribes
+ # set something special up -- something that subscribes
# every startup...
es.subscribe(
PathSubscriber(wrapped_self),
clean_self._subscribeToServiceInterface,
- clean_self._subscribeToServiceFilter)
+ clean_self._subscribeToServiceFilter
+ )
- bound=ContextMethod(bound)
+ bound = ContextMethod(bound)
def unbound(wrapped_self, name):
"see IBindingAware"
- clean_self=removeAllProxies(wrapped_self)
- subscriber=PathSubscriber(wrapped_self)
+ clean_self = removeAllProxies(wrapped_self)
+ subscriber = PathSubscriber(wrapped_self)
for subscription in clean_self._subscriptions:
- subscribable=getAdapter(
+ subscribable = getAdapter(
wrapped_self, ITraverser).traverse(subscription[0])
subscribable.unsubscribe(subscriber)
clean_self._subscriptions = ()
clean_self._serviceName = None
- unbound=ContextMethod(unbound)
+ unbound = ContextMethod(unbound)