[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IServiceService.py:1.1.2.7 Service.py:1.1.6.11 ServiceManagerContainer.py:1.1.2.3 __init__.py:1.1.6.18 component.zcml:1.1.2.3 hooks.py:1.1.2.22
Gary Poster
garyposter@earthlink.net
Wed, 17 Apr 2002 15:13:07 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv31331/ComponentArchitecture
Modified Files:
Tag: Zope-3x-branch
IServiceService.py Service.py ServiceManagerContainer.py
__init__.py component.zcml hooks.py
Log Message:
This commit makes the following changes:
The hookable zcml mechanism now requires an intermediary method to overwrite: see the hookables in Zope.ComponentArchitecture for an example
IServiceService, Service, and ServiceManager now all have this signature for the getService method: name. They did use context, name. The context, name signature is still used for the main ComponentArchitecture getService function.
the getServiceDefinition function now requires context
A ServiceContainer returns a wrapped ServiceManager; a ServiceManager returns a wrapped Service.
ServiceManager now overrides two ComponentArchitecture hooks: getServiceManager and getNextServiceManager
getNextServiceManager and getNextService are two new ComponentArchitecture functions useful for placeful services
The Zope.Publisher.Browser.BrowserRequest now includes the Zope2 class definition of record: this means that the placeful RoleService is inching forward towards working.
tests have been updated to reflect these changes.
=== Zope3/lib/python/Zope/ComponentArchitecture/IServiceService.py 1.1.2.6 => 1.1.2.7 ===
"""
- def getService(object, name):
+ def getService(name):
"""retrieve a service implementation
Default implimentations search the context for the next
=== Zope3/lib/python/Zope/ComponentArchitecture/Service.py 1.1.6.10 => 1.1.6.11 ===
self.__services[name] = component
- def getService(self, object, name):
+ def getService(self, name):
"""retrieve a service implementation"""
try:
@@ -89,20 +89,5 @@
addCleanUp(_clear)
del addCleanUp
-# 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):
+def getGlobalServiceManager():
return serviceManager
-
-_getGlobalServiceManager=_getServiceManager
-
-def _getService(object, name):
- return serviceManager.getService(object, name)
-
-def _getServiceDefinitions(): # this needs context if we want it to be placeful
- """
- get service defintions from component architecture service
- manager.
- """
- return serviceManager.getServiceDefinitions()
=== Zope3/lib/python/Zope/ComponentArchitecture/ServiceManagerContainer.py 1.1.2.2 => 1.1.2.3 ===
from IServiceService import IServiceService
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+from Zope.ContextWrapper import Wrapper
_marker = object()
@@ -40,7 +41,7 @@
'''See interface IServiceManagerContainer'''
try:
- return self.__sm
+ return Wrapper(self.__sm, self) # no name?
except AttributeError:
if default is _marker:
raise ComponentLookupError
=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.1.6.17 => 1.1.6.18 ===
from hooks import provideUtility, getUtility
from hooks import provideFactory, createObject
+from hooks import getServiceManager, getNextServiceManager, \
+ getService, getServiceDefinitions, getNextService
from Service import defineService, provideService
-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 Service import 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.2 => 1.1.2.3 ===
component='Zope.ComponentArchitecture.ViewService.viewService' />
-<hookable name=".getServiceManager" />
-<hookable name=".getService" />
-<hookable name=".getServiceDefinitions" />
+<hookable module=".hooks" name="getServiceManager" />
+<hookable module=".hooks" name="getNextServiceManager" />
+<hookable module=".hooks" name="getService" />
+<hookable module=".hooks" name="getServiceDefinitions" />
+<hookable module=".hooks" name="getNextService" />
+<hookable module=".hooks" name="getAdapter" />
+<hookable module=".hooks" name="provideAdapter" />
+<hookable module=".hooks" name="getUtility" />
+<hookable module=".hooks" name="provideUtility" />
+<hookable module=".hooks" name="createObject" />
+<hookable module=".hooks" name="provideFactory" />
</zopeConfigure>
=== Zope3/lib/python/Zope/ComponentArchitecture/hooks.py 1.1.2.21 => 1.1.2.22 ===
from Exceptions import ComponentLookupError
+from Service import serviceManager
_marker=[]
def provideAdapter(forInterface, providedInterface, maker):
@@ -39,7 +40,45 @@
def createObject(place, name, *args, **kwargs):
return createObject_hook(place, name, args, kwargs)
+def getServiceManager(context):
+ return getServiceManager_hook(context)
+
+def getNextServiceManager(context):
+ return getNextServiceManager_hook(context)
+
+def getService(context, name):
+ return getService_hook(context, name)
+
+def getServiceDefinitions(context):
+ return getServiceDefinitions_hook(context)
+
+def getNextService(context, name):
+ return getNextService_hook(context, name)
+
# default hooks
+
+def getServiceManager_hook(context):
+ return serviceManager
+
+def getNextServiceManager_hook(context):
+ return None
+
+def getService_hook(context, name):
+ return getServiceManager(context).getService(name)
+
+def getServiceDefinitions_hook(context):
+ """
+ context based lookup to get service defintions
+ """
+ return getServiceManager(context).getServiceDefinitions()
+
+def getNextService_hook(context, name):
+ """assuming the context is a service manager or placeful service,
+ tries to return the next highest service matching name."""
+ sm=getNextServiceManager(context)
+ if sm:
+ return sm.getService(name)
+ return None
from IToIRegistry import IToIRegistry, IRegistry