[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.24

Jim Fulton jim at zope.com
Mon Mar 15 15:42:52 EST 2004


Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv3759/src/zope/component

Modified Files:
	__init__.py 
Log Message:
Changed queryMultiAdapter to make the context optional.

Changes the subscription api.


=== Zope3/src/zope/component/__init__.py 1.23 => 1.24 ===
--- Zope3/src/zope/component/__init__.py:1.23	Tue Mar  9 19:58:31 2004
+++ Zope3/src/zope/component/__init__.py	Mon Mar 15 15:42:21 2004
@@ -123,7 +123,10 @@
     try:
         adapters = getService(ob, Adapters)
     except ComponentLookupError:
-        # Oh blast, no adapter service. We're probably just running from a test
+        
+        # Oh blast, no adapter service. We're probably just running
+        # from a test
+
         return None
 
     return adapters.queryNamedAdapter(ob, iface, '')
@@ -131,7 +134,11 @@
 from zope.interface.interface import adapter_hooks
 adapter_hooks.append(interfaceAdapterHook)
 
-def queryMultiAdapter(objects, interface, context, name=u'', default=None):
+def queryMultiAdapter(objects, interface, name=u'', default=None,
+                      context=None):
+    if context is None and objects:
+        context = objects[0]
+        
     try:
         adapters = getService(context, Adapters)
     except ComponentLookupError:
@@ -140,28 +147,16 @@
 
     return adapters.queryMultiAdapter(objects, interface, name, default)
 
-def querySubscriptionAdapter(object, interface, name, default=(),
-                             context=None):
-    if context is None:
-        context = object
-    try:
-        adapters = getService(context, Adapters)
-    except ComponentLookupError:
-        # Oh blast, no adapter service. We're probably just running from a test
-        return default
-
-    return adapters.querySubscriptionAdapter(object, interface, name, default)
-
-def querySubscriptionMultiAdapter(objects, interface, context, name=u'',
-                             default=()):
+def subscribers(objects, interface, context=None):
+    if context is None and objects:
+        context = objects[0]
     try:
         adapters = getService(context, Adapters)
     except ComponentLookupError:
         # Oh blast, no adapter service. We're probably just running from a test
-        return default
+        return []
+    return adapters.subscribers(objects, interface)
 
-    return adapters.querySubscriptionMultiAdapter(objects, interface, name,
-                                                  default)
 
 # Factories
 




More information about the Zope3-Checkins mailing list