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

Jim Fulton jim at zope.com
Fri Mar 5 19:39:19 EST 2004


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

Modified Files:
	__init__.py 
Log Message:
Added an interface __adapt__ hook.


=== Zope3/src/zope/component/__init__.py 1.19 => 1.20 ===
--- Zope3/src/zope/component/__init__.py:1.19	Fri Mar  5 17:09:25 2004
+++ Zope3/src/zope/component/__init__.py	Fri Mar  5 19:38:47 2004
@@ -120,6 +120,18 @@
 
 queryNamedAdapter = hookable(queryNamedAdapter)
 
+def interfaceAdapterHook(iface, ob):
+    try:
+        adapters = getService(ob, Adapters)
+    except ComponentLookupError:
+        # Oh blast, no adapter service. We're probably just running from a test
+        return None
+
+    return adapters.queryNamedAdapter(ob, iface, '')
+
+from zope.interface.interface import adapter_hooks
+adapter_hooks.append(interfaceAdapterHook)
+
 def queryMultiAdapter(objects, interface, context, name=u'', default=None):
     try:
         adapters = getService(context, Adapters)




More information about the Zope3-Checkins mailing list