[Zope3-checkins] SVN: Zope3/trunk/ Fix #392 : adapter registry subscribers method can return None when it should not

Julien Anguenot ja at nuxeo.com
Mon May 23 21:23:32 EDT 2005


Log message for revision 30486:
  Fix #392 : adapter registry subscribers method can return None when it should not

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/interface/adapter.py
  U   Zope3/trunk/src/zope/interface/adapter.txt

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2005-05-23 21:17:22 UTC (rev 30485)
+++ Zope3/trunk/doc/CHANGES.txt	2005-05-24 01:23:01 UTC (rev 30486)
@@ -599,6 +599,9 @@
 
     Bug Fixes
 
+      - Fix #392 : adapter registry subscribers method can return None
+        when it shouldn't
+
       - Fix 'Wiki permissions and PAU' bug reported by Paolo Invernizzi
 
       - Assert location if a non-public permission was specified within an

Modified: Zope3/trunk/src/zope/interface/adapter.py
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.py	2005-05-23 21:17:22 UTC (rev 30485)
+++ Zope3/trunk/src/zope/interface/adapter.py	2005-05-24 01:23:01 UTC (rev 30486)
@@ -406,7 +406,6 @@
             adapter = factory(object)
             if adapter is not None:
                 return adapter
-
         return default
 
     def queryAdapter(self, object, interface, name='', default=None):
@@ -414,7 +413,6 @@
         # We usually end up calling adapter_hook
         return self.adapter_hook(interface, object, name, default)
 
-
     def subscriptions(self, required, provided):
         if provided is None:
             provided = Null
@@ -473,7 +471,10 @@
 
     def subscribers(self, objects, interface):
         subscriptions = self.subscriptions(map(providedBy, objects), interface)
-        return [subscription(*objects) for subscription in subscriptions]
+        subscribers = [subscription(*objects)
+                       for subscription in subscriptions]
+        # Filter None values
+        return [x for x in subscribers if x is not None]
 
     def get(self, declaration):
         if declaration is None:

Modified: Zope3/trunk/src/zope/interface/adapter.txt
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.txt	2005-05-23 21:17:22 UTC (rev 30485)
+++ Zope3/trunk/src/zope/interface/adapter.txt	2005-05-24 01:23:01 UTC (rev 30486)
@@ -487,7 +487,16 @@
   >>> [(s.x is x and s.q is q) for s in subscribers]
   [True, True]
 
+adapter factory subcribers can't return None values
 
+  >>> def M3(x, y):
+  ...     return None
+
+  >>> registry.subscribe([IR, IQ], IM, M3)
+  >>> subscribers = registry.subscribers((x, q), IM)
+  >>> len(subscribers)
+  2
+
 Handlers
 --------
 



More information about the Zope3-Checkins mailing list