[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/LocalEventService - LocalEventChannel.py:1.8 LocalEventService.py:1.12 ProtoServiceEventChannel.py:1.5 LocalServiceSubscribable.py:1.10 LocalSubscribable.py:1.8

Ulrich Eck ueck@net-labs.de
Thu, 12 Dec 2002 15:27:39 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/LocalEventService
In directory cvs.zope.org:/tmp/cvs-serv1388

Modified Files:
	LocalEventChannel.py LocalEventService.py 
	ProtoServiceEventChannel.py LocalServiceSubscribable.py 
	LocalSubscribable.py 
Log Message:
Sorry folks, i didn't switch to my branch and checked into head
accidently. With this checkin i revert all changed made and
go into my branch.

sorry .. won't happen again.


=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventChannel.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventChannel.py:1.7	Thu Dec 12 15:05:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventChannel.py	Thu Dec 12 15:27:39 2002
@@ -21,7 +21,7 @@
 from Zope.Event.IEventChannel import IEventChannel
 from Zope.ContextWrapper import ContextMethod
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
-from Zope.App.Traversing import traverse
+from Zope.Proxy.ContextWrapper import ContextWrapper
 
 class LocalEventChannel(LocalSubscribable):
     
@@ -38,10 +38,8 @@
         # subscriptionses = clean_self._registry.getAllForObject(event)
 
         for subscriptions in subscriptionses:
-            # for subscriber_path, filter in subscriptions:
-            for subscriber_path, filter in subscriptions:
+            for subscriber,filter in subscriptions:
                 if filter is not None and not filter(event):
                     continue
-                # XXX resolve subscriber_path
-                traverse(wrapped_self, subscriber_path).notify(event)
+                ContextWrapper(subscriber, wrapped_self).notify(event)
     notify = ContextMethod(notify)


=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventService.py 1.11 => 1.12 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventService.py:1.11	Thu Dec 12 15:05:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalEventService.py	Thu Dec 12 15:27:39 2002
@@ -22,7 +22,6 @@
 from Zope.Event.IEventService import IEventService
 from Zope.Event.ISubscriptionAware import ISubscriptionAware
 from Zope.App.Traversing.ITraverser import ITraverser
-from Zope.App.Traversing import traverse
 from Zope.ComponentArchitecture import getAdapter, getService
 from Zope.App.ComponentArchitecture.NextService import getNextService
 from Zope.ContextWrapper import ContextMethod
@@ -30,8 +29,7 @@
 from Zope.Proxy.ContextWrapper import ContextWrapper
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
 
-
-
+from PathSubscriber import PathSubscriber
 from ProtoServiceEventChannel import ProtoServiceEventChannel
 
 class LocalEventService(ProtoServiceEventChannel):
@@ -60,12 +58,10 @@
         subscriptionses = clean_self._registry.getAllForObject(event)
 
         for subscriptions in subscriptionses:
-            # for subscriber_path, filter in subscriptions:
-            for subscriber_path,filter in subscriptions:
+            for subscriber,filter in subscriptions:
                 if filter is not None and not filter(event):
                     continue
-                # XXX resolve subscriber_path
-                traverse(wrapped_self, subscriber_path).notify(event)
+                ContextWrapper(subscriber, wrapped_self).notify(event)
 
         publishedEvents = getattr(clean_self, "_v_publishedEvents", None)
         if publishedEvents is None:
@@ -85,12 +81,10 @@
             subscriptionses = clean_self._registry.getAllForObject(event)
 
             for subscriptions in subscriptionses:
-                # for subscriber_path, filter in subscriptions:
-                for subscriber_path, filter in subscriptions:
+                for subscriber,filter in subscriptions:
                     if filter is not None and not filter(event):
                         continue
-                    # XXX resolve subscriber_path
-                    traverse(wrapped_self, subscriber_path).notify(event)
+                    ContextWrapper(subscriber, wrapped_self).notify(event)
     notify = ContextMethod(notify)
     
     def bound(wrapped_self, name):
@@ -104,8 +98,7 @@
                 # global event service we're going to have to
                 # set something special up--something that subscribes
                 # every startup...
-                # XXX just pass wrapped_self
-                es.subscribe(wrapped_self)
+                es.subscribe(PathSubscriber(wrapped_self))
     bound = ContextMethod(bound)
     
     # _unbound = ProtoServiceEventChannel.unbound # see comment below
@@ -127,34 +120,29 @@
         #
         # so we're doing a copy and paste from ProtoServiceEventChannel:
         # start copy/paste
-        # XXX subscriber = wrapped_self
+        subscriber = PathSubscriber(wrapped_self)
         for subscription in clean_self._subscriptions:
             subscribable = getAdapter(
                 wrapped_self, ITraverser).traverse(subscription[0])
-            subscribable.unsubscribe(wrapped_self)
+            subscribable.unsubscribe(subscriber)
         clean_self._subscriptions = ()
         clean_self._serviceName = None
         # end copy/paste
         
-        # ambigous name subscriber -> (subscriber_path, filter, )
         for subscriber in clean_self._subscribers:
             clean_self.__unsubscribeAllFromSelf(wrapped_self, subscriber[0])
         # unset flag
         clean_self._v_unbinding = None
     unbound = ContextMethod(unbound)
     
-    # XXX gets subscriber_path as last argument
-    def __unsubscribeAllFromSelf(clean_self, wrapped_self, subscriber_path):
+    def __unsubscribeAllFromSelf(clean_self, wrapped_self, subscriber):
         """this is *not* an interface function, and should not be used
         outside of this class"""
-        
-        # XXX resolve subscriber from path first
-        subscriber = traverse(wrapped_self, subscriber_path)
+        wrapped_subscriber = ContextWrapper(subscriber, wrapped_self)
         
         for subscriber_index in range(len(clean_self._subscribers)):
             sub = clean_self._subscribers[subscriber_index]
-            # XXX subscriber_path
-            if sub[0] == subscriber_path:
+            if sub[0] == subscriber:
                 ev_set = sub[1]
                 break
         else:
@@ -166,10 +154,9 @@
             subs=subscriptions[:]
             subscriptions[:] = []
             for sub in subs:
-                # XXX subscriber_path
-                if sub[0] == subscriber_path: # deleted (not added back)
+                if sub[0] == subscriber: # deleted (not added back)
                     if do_alert:
-                        subscriber.unsubscribedFrom(
+                        wrapped_subscriber.unsubscribedFrom(
                             wrapped_self, ev_type or IEvent, sub[1])
                         # IEvent switch is to make optimization transparent
                 else: # kept (added back)
@@ -202,8 +189,6 @@
                 # service...
                 # that leaves replacing top level event services an
                 # interesting question, however
-                
-                # XXX just pass wrapped_self
-                context.subscribe(wrapped_self)
+                context.subscribe(PathSubscriber(wrapped_self))
     unsubscribedFrom = ContextMethod(unsubscribedFrom)
 


=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/ProtoServiceEventChannel.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/ProtoServiceEventChannel.py:1.4	Thu Dec 12 15:05:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/ProtoServiceEventChannel.py	Thu Dec 12 15:27:39 2002
@@ -21,6 +21,7 @@
 from Zope.App.Traversing.ITraverser import ITraverser
 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 LocalEventChannel import LocalEventChannel
@@ -74,7 +75,7 @@
                 # set something special up -- something that subscribes
                 # every startup...
                 es.subscribe(
-                    wrapped_self,
+                    PathSubscriber(wrapped_self),
                     clean_self._subscribeToServiceInterface,
                     clean_self._subscribeToServiceFilter
                     )
@@ -84,10 +85,11 @@
     def unbound(wrapped_self, name):
         "see IBindingAware"
         clean_self = removeAllProxies(wrapped_self)
+        subscriber = PathSubscriber(wrapped_self)
         for subscription in clean_self._subscriptions:
             subscribable = getAdapter(
                 wrapped_self, ITraverser).traverse(subscription[0])
-            subscribable.unsubscribe(wrapped_self)
+            subscribable.unsubscribe(subscriber)
         clean_self._subscriptions = ()
         clean_self._serviceName = None
 


=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalServiceSubscribable.py 1.9 => 1.10 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalServiceSubscribable.py:1.9	Thu Dec 12 15:05:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalServiceSubscribable.py	Thu Dec 12 15:27:39 2002
@@ -24,7 +24,6 @@
 from Zope.Proxy.ContextWrapper import ContextWrapper
 from LocalSubscribable import LocalSubscribable
 from Zope.App.ComponentArchitecture.NextService import getNextService, queryNextService
-from Zope.App.Traversing import getPhysicalPathString
 
 class LocalServiceSubscribable(LocalSubscribable):
     """a local mix-in for services"""
@@ -41,15 +40,15 @@
                     subscriber,
                     event_type=None,
                     filter=None):
-        # subscriber must be wrapped
-        subscriber_path = getPhysicalPathString(subscriber)
+        # might be wrapped, might not
+        subscriber = removeAllProxies(subscriber) 
         
         clean_self = removeAllProxies(wrapped_self)
+        wrapped_subscriber = ContextWrapper(subscriber, wrapped_self)
         
         for subscriber_index in range(len(clean_self._subscribers)):
             sub = clean_self._subscribers[subscriber_index]
-            # XXX subscriber_path
-            if sub[0] == subscriber_path:
+            if sub[0] == subscriber:
                 ev_set = sub[1]
                 break
         else:
@@ -77,17 +76,15 @@
             else:
                 subscriptions = clean_self._registry.get(ev_type)
                 try:
-                    # XXX subscriber_path
-                    subscriptions.remove((subscriber_path, filter))
+                    subscriptions.remove((subscriber, filter))
                 except ValueError:
                     raise NotFoundError(subscriber, event_type, filter)
                 if do_alert:
-                    subscriber.unsubscribedFrom(
+                    wrapped_subscriber.unsubscribedFrom(
                         wrapped_self, event_type, filter)
                 if len(ev_set) == 1:
                     for sub in subscriptions:
-                        # XXX subscriber_path
-                        if sub[0] == subscriber_path:
+                        if sub[0] == subscriber:
                             break
                     else:
                         del clean_self._subscribers[subscriber_index]
@@ -98,10 +95,9 @@
                 subs = subscriptions[:]
                 subscriptions[:] = []
                 for sub in subs:
-                    # XXX subscriber_path
-                    if sub[0] == subscriber_path: # deleted (not added back)
+                    if sub[0] == subscriber: # deleted (not added back)
                         if do_alert:
-                            subscriber.unsubscribedFrom(
+                            wrapped_subscriber.unsubscribedFrom(
                                 wrapped_self, ev_type or IEvent, sub[1])
                             # IEvent switch is to make optimization
                             # transparent (see *** comment above in
@@ -116,8 +112,9 @@
     unsubscribe = ContextMethod(unsubscribe)
     
     def listSubscriptions(wrapped_self, subscriber, event_type=None):
-        # subscriber must be wrapped
-       
+        # might be wrapped, might not
+        subscriber = removeAllProxies(subscriber)
+        
         clean_self = removeAllProxies(wrapped_self)
         result = LocalSubscribable.listSubscriptions(
             clean_self, subscriber, event_type)


=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscribable.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscribable.py:1.7	Thu Dec 12 15:05:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/LocalSubscribable.py	Thu Dec 12 15:27:39 2002
@@ -25,8 +25,6 @@
 from Zope.Proxy.ContextWrapper import ContextWrapper
 from Zope.Event.Subscribable import Subscribable
 from Persistence import Persistent
-from Zope.App.Traversing import traverse, getPhysicalPathString
-from Zope.App.Traversing import locationAsUnicode
 
 class LocalSubscribable(Persistent, Subscribable):
     """a local mix-in"""
@@ -41,14 +39,14 @@
                   subscriber,
                   event_type=IEvent,
                   filter=None):
+        # might be wrapped, might not
+        subscriber = removeAllProxies(subscriber)
         
-        # subscriber needs to be wrapped
-        subscriber_path = getPhysicalPathString(subscriber)
-       
         clean_self = removeAllProxies(wrapped_self)
+        wrapped_subscriber = ContextWrapper(subscriber, wrapped_self)
         
         if ISubscriptionAware.isImplementedBy(subscriber):
-            subscriber.subscribedTo(
+            wrapped_subscriber.subscribedTo(
                 wrapped_self,
                 event_type,
                 filter)
@@ -60,18 +58,15 @@
         if subscribers is None:
             subscribers = []
             clean_self._registry.register(ev_type, subscribers)
-        # XXX subscriber_path
-        subscribers.append((subscriber_path, filter))
+        subscribers.append((subscriber, filter))
 
         subs = clean_self._subscribers
         for sub in subs:
-            # XXX subscriber_path
-            if sub[0] == subscriber_path:
+            if sub[0] == subscriber:
                 sub[1][ev_type] = 1
                 break
         else:
-            # XXX subscriber_path
-            subs.append((subscriber_path,{ev_type:1}))
+            subs.append((subscriber,{ev_type:1}))
         
         clean_self._p_changed = 1 #trigger persistence
         # XXX should this and similar be done earlier in the method?
@@ -84,15 +79,15 @@
                     subscriber,
                     event_type = None,
                     filter = None):
-        # subscriber must be wrapped
-        subscriber_path = getPhysicalPathString(subscriber)
+        # subscriber might be wrapped, might not
+        subscriber = removeAllProxies(subscriber) 
         
         clean_self = removeAllProxies(wrapped_self)
+        wrapped_subscriber = ContextWrapper(subscriber, wrapped_self)
         
         for subscriber_index in range(len(clean_self._subscribers)):
             sub = clean_self._subscribers[subscriber_index]
-            # XXX subscriber_path
-            if sub[0] == subscriber_path:
+            if sub[0] == subscriber:
                 ev_set = sub[1]
                 break
         else:
@@ -111,17 +106,15 @@
             if not subscriptions:
                 raise NotFoundError(subscriber, event_type, filter)
             try:
-                # XXX subscriber_path
-                subscriptions.remove((subscriber_path, filter))
+                subscriptions.remove((subscriber, filter))
             except ValueError:
                 raise NotFoundError(subscriber, event_type, filter)
             if do_alert:
-                subscriber.unsubscribedFrom(
+                wrapped_subscriber.unsubscribedFrom(
                     wrapped_self, event_type, filter)
             if len(ev_set) == 1:
                 for sub in subscriptions:
-                    # XXX subscriber_path
-                    if sub[0] == subscriber_path:
+                    if sub[0] == subscriber:
                         break
                 else:
                     del clean_self._subscribers[subscriber_index]
@@ -131,10 +124,9 @@
                 subs=subscriptions[:]
                 subscriptions[:] = []
                 for sub in subs:
-                    # XXX subscriber_path
-                    if sub[0] == subscriber_path: # deleted (not added back)
+                    if sub[0] == subscriber: # deleted (not added back)
                         if do_alert:
-                            subscriber.unsubscribedFrom(
+                            wrapped_subscriber.unsubscribedFrom(
                                 wrapped_self, ev_type or IEvent, sub[1])
                             # IEvent switch is to make optimization
                             # transparent
@@ -145,36 +137,3 @@
         # XXX should be done earlier?  Ask Shane
     
     unsubscribe = ContextMethod(unsubscribe)
-
-    def listSubscriptions(self, subscriber, event_type=None):
-        # subscriber must be wrapped
-        subscriber_path = getPhysicalPathString(subscriber)
-        
-        result=[]
-        if event_type:
-            ev_type=event_type
-            if event_type is IEvent:
-                ev_type=None # handle optimization
-            subscriptions = self._registry.get(ev_type)
-            if subscriptions:
-                for sub in subscriptions:
-                    # XXX subscriber_path
-                    if sub[0]==subscriber_path:
-                        result.append((event_type, sub[1]))
-        else:
-            for subscriber_index in range(len(self._subscribers)):
-                sub=self._subscribers[subscriber_index]
-                # XXX subscriber_path
-                if sub[0]==subscriber_path:
-                    ev_set=sub[1]
-                    break
-            else:
-                return result
-            for ev_type in ev_set:
-                subscriptions = self._registry.get(ev_type)
-                if subscriptions:
-                    for sub in subscriptions:
-                        # XXX subscriber_path
-                        if sub[0]==subscriber_path:
-                            result.append((ev_type or IEvent, sub[1]))
-        return result