[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/LocalEventService - PathSubscriber.py:1.5

Gary Poster gary@zope.com
Thu, 12 Dec 2002 16:05:48 -0500


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

Modified Files:
	PathSubscriber.py 
Log Message:
Preparation for an ObjectHub subscriber; fixing cacheing possible problem



=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/PathSubscriber.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/PathSubscriber.py:1.4	Thu Jul 11 14:21:31 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/PathSubscriber.py	Thu Dec 12 16:05:48 2002
@@ -27,42 +27,44 @@
 
 from Zope.ContextWrapper import ContextMethod
 
-
-class PathSubscriber:
-    
-    __implements__=IPathSubscriber, ISubscriptionAware
-    
-    def __init__(self, wrapped_subscriber):
-        self.subscriber_path = getPhysicalPathString(wrapped_subscriber)
-        self.__alert_subscription=ISubscriptionAware.isImplementedBy(
-            removeAllProxies(wrapped_subscriber) )
-    
-    def __eq__(self, other):
-        return IPathSubscriber.isImplementedBy(other) and \
-               other.subscriber_path == self.subscriber_path
-    
-    def __getSubscriber(self, wrapped_self):
-        return traverse(wrapped_self, self.subscriber_path)
+class AbstractIndirectSubscriber:
     
     def notify(wrapped_self, event):
-        removeAllProxies(wrapped_self).__getSubscriber(
+        removeAllProxies(wrapped_self)._getSubscriber(
             wrapped_self).notify(event)
     
     notify=ContextMethod(notify)
     
     def subscribedTo(wrapped_self, subscribable, event_type, filter):
-        clean_self=removeAllProxies(wrapped_self)
-        if clean_self.__alert_subscription:
-            clean_self.__getSubscriber(wrapped_self).subscribedTo(
+        proxiedObj = removeAllProxies(
+            wrapped_self)._getSubscriber(wrapped_self)
+        if ISubscriptionAware.isImplementedBy(
+            removeAllProxies(proxiedObj)):
+            proxiedObj.subscribedTo(
                 subscribable, event_type, filter )
     
     subscribedTo=ContextMethod(subscribedTo)
     
     def unsubscribedFrom(wrapped_self, subscribable, event_type, filter):
-        clean_self=removeAllProxies(wrapped_self)
-        if clean_self.__alert_subscription:
-            clean_self.__getSubscriber(wrapped_self).unsubscribedFrom(
+        proxiedObj = removeAllProxies(
+            wrapped_self)._getSubscriber(wrapped_self)
+        if ISubscriptionAware.isImplementedBy(
+            removeAllProxies(proxiedObj)):
+            proxiedObj.unsubscribedFrom(
                 subscribable, event_type, filter )
     
     unsubscribedFrom=ContextMethod(unsubscribedFrom)
+
+class PathSubscriber(AbstractIndirectSubscriber):
+    
+    __implements__ = IPathSubscriber, ISubscriptionAware
+    
+    def __init__(self, wrapped_subscriber):
+        self.subscriber_path = getPhysicalPathString(wrapped_subscriber)
+    
+    def __eq__(self, other):
+        return (IPathSubscriber.isImplementedBy(other) and 
+               other.subscriber_path == self.subscriber_path)
     
+    def _getSubscriber(self, wrapped_self):
+        return traverse(wrapped_self, self.subscriber_path)