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

Jim Fulton jim@zope.com
Sun, 18 May 2003 14:07:14 -0400


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

Modified Files:
	__init__.py 
Log Message:
Updated hook configuration to use the new hooking machinery.

Also simplified hook zcml configuration. It is no longer necessary to
declare that something is hookable before hooking it. After all, we
can now introspect objects to determine if they are hookable.


=== Zope3/src/zope/component/__init__.py 1.7 => 1.8 ===
--- Zope3/src/zope/component/__init__.py:1.7	Fri Apr 18 18:12:30 2003
+++ Zope3/src/zope/component/__init__.py	Sun May 18 14:06:44 2003
@@ -23,10 +23,14 @@
 from zope.component.servicenames import Adapters, Skins, Resources
 from zope.component.servicenames import Factories
 
-moduleProvides(IComponentArchitecture)
+# Try to be hookable. Do so in a try/except to avoid a hard dependence
+try:
+    from zope.hookable import hookable
+except ImportError:
+    def hookable(ob):
+        return ob
 
-def getServiceManager(context): # hookable
-    return getServiceManager_hook(context)
+moduleProvides(IComponentArchitecture)
 
 def queryServiceManager(context, default=None):
     try:
@@ -34,8 +38,9 @@
     except ComponentLookupError:
         return default
 
-def getServiceManager_hook(context): # default hook
+def getServiceManager(context):
     return serviceManager
+getServiceManager = hookable(getServiceManager)
 
 def getService(context, name):
     return getServiceManager(context).getService(name)