[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - Service.py:1.1.6.10 __init__.py:1.1.6.17 component.zcml:1.1.2.2

Gary Poster garyposter@earthlink.net
Sun, 14 Apr 2002 23:32:00 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv19265/ComponentArchitecture

Modified Files:
      Tag: Zope-3x-branch
	Service.py __init__.py component.zcml 
Log Message:
This commit sets up the hook tag so that it actually works, and uses the new functionality to better divide up the labor of the ComponentArchitecture.  The placeless ComponentArchitecture code for getService is still there, but the placeful code has been moved to the ServiceManager section.  A few other hooks are also set up in ComponentArchitecture, and a few changes made in preparation for a later update of some placeful services.

The ServiceManager test was altered to use the newly moved placeful getService code.

Other hooks can now be set up and used using this hopefully helpful mechanism.



=== Zope3/lib/python/Zope/ComponentArchitecture/Service.py 1.1.6.9 => 1.1.6.10 ===
 del addCleanUp
 
-def getService(object, name):
-    """
-    context based lookup, with fallback to component architecture
-    service manager if no service manager found within context
-    """
-    while object is not None:
-        if IServiceManagerContainer.isImplementedBy(object):
-            sm = object.getServiceManager(None)
-            if sm is not None:
-                return sm.getService(object, name)
-        object = getinnercontext(object)
+# below are imported in ComponentArchitecture __init__ without underline
+# (i.e., don't use these, use the hookable imported versions in the package itself)
+
+def _getServiceManager(context):
+    return serviceManager
+
+_getGlobalServiceManager=_getServiceManager
+
+def _getService(object, name):
     return serviceManager.getService(object, name)
 
-def getServiceDefinitions():
+def _getServiceDefinitions(): # this needs context if we want it to be placeful
     """
     get service defintions from component architecture service
     manager.


=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.1.6.16 => 1.1.6.17 ===
 from hooks import provideFactory, createObject
 from Service import defineService, provideService
-from Service import getService, getServiceDefinitions
+from Service import _getServiceManager as getServiceManager # hookable
+from Service import _getService as getService # hookable
+from Service import _getServiceDefinitions as getServiceDefinitions # hookable
+from Service import _getGlobalServiceManager as getGlobalServiceManager
 from SkinService import getSkin, defineSkin
 from ViewService import getView, provideView, getRequestView
 from ViewService import getDefaultViewName, getRequestDefaultViewName, \


=== Zope3/lib/python/Zope/ComponentArchitecture/component.zcml 1.1.2.1 => 1.1.2.2 ===
          component='Zope.ComponentArchitecture.ViewService.viewService' />
 
+<hookable name=".getServiceManager" />
+<hookable name=".getService" />
+<hookable name=".getServiceDefinitions" />
+
 </zopeConfigure>