[Zope3-checkins] CVS: Zope3/src/zope/app/services - event.py:1.21

Steve Alexander steve@cat-box.net
Sat, 12 Apr 2003 07:42:08 -0400


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv17937/src/zope/app/services

Modified Files:
	event.py 
Log Message:
Added logging statements to say when subscription on bind was not
successful.


=== Zope3/src/zope/app/services/event.py 1.20 => 1.21 ===
--- Zope3/src/zope/app/services/event.py:1.20	Sun Mar 16 10:44:05 2003
+++ Zope3/src/zope/app/services/event.py	Sat Apr 12 07:42:08 2003
@@ -37,6 +37,7 @@
 
 from zope.app.event.subs import Subscribable, SubscriptionTracker
 
+import logging
 
 def getSubscriptionService(context):
     return getService(context, EventSubscription)
@@ -113,7 +114,9 @@
                 getAdapter(obj, ISubscriber).notify(event)
 
         for subscriber in badSubscribers:
-            # XXX this ought to be logged
+            logging.getLogger('SiteError').warn(
+                "Notifying a subscriber that does not exist."
+                " Unsubscribing it: %s" % subscriber)
             # Also, is it right that we should sometimes have
             # "write caused by a read" semantics? I'm seeing notify() as
             # basically a read, and (un)subscribe as a write.
@@ -175,7 +178,14 @@
                 if removeAllProxies(es) is clean_self:
                     es = queryNextService(
                         wrapped_self, clean_self._subscribeToServiceName)
-            if es is not None:
+            if es is None:
+                subscribe_to = clean_self._subscribeToServiceName
+                logging.getLogger('SiteError').warn(
+                    "Unable to subscribe %s service to the %s service "
+                    "while binding the %s service. This is because the "
+                    "%s service could not be found." %
+                    (name, subscribe_to, name, subscribe_to))
+            else:
                 es.subscribe(
                     wrapped_self,
                     clean_self._subscribeToServiceInterface,