[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - ServiceManager.py:1.3 configure.zcml:1.4 hooks.py:NONE
Jim Fulton
jim@zope.com
Tue, 2 Jul 2002 19:44:44 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv17483/lib/python/Zope/App/OFS/Services/ServiceManager
Modified Files:
ServiceManager.py configure.zcml
Removed Files:
hooks.py
Log Message:
Refactored service manager and service lookup get routines to be
consistent with the Zope 3 get style, using get and query
routines. Added some missing tests.
Moved the service-manager lookup hooks to
Zope.App.ComponentArchitecture.
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py 1.2 => 1.3 ===
$Id$
"""
+from Zope.Exceptions import NotFoundError, ZopeError
-from IServiceManager import IServiceManager
from Zope.ComponentArchitecture.IServiceManagerContainer \
import IServiceManagerContainer
-from Zope.ComponentArchitecture import getService, \
- getNextServiceManager, getNextService
+from Zope.ComponentArchitecture \
+ import getService, getNextServiceManager, getNextService
from Zope.ComponentArchitecture.GlobalServiceManager import UndefinedService
from Zope.ComponentArchitecture.GlobalServiceManager import InvalidService
-from Zope.Exceptions import NotFoundError, ZopeError
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+
from Zope.App.OFS.Content.Folder.Folder import Folder
from Zope.ContextWrapper import ContextMethod
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
from IBindingAware import IBindingAware
+from IServiceManager import IServiceManager
+
class ServiceManager(BTreeContainer):
@@ -64,6 +68,14 @@
return serviceDefs
getServiceDefinitions=ContextMethod(getServiceDefinitions)
+
+ def queryService(self, name, default=None):
+ try:
+ return self.getService(name)
+ except ComponentLookupError:
+ return default
+
+ queryService=ContextMethod(queryService)
def getService(wrapped_self, name):
""" see IServiceManager Interface"""
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml 1.3 => 1.4 ===
<include package="Zope.App.OFS.Services.ServiceManager.Views" />
- <hook module="Zope.ComponentArchitecture"
- name="getServiceManager"
- implementation=".hooks.getServiceManager_hook" />
- <hook module="Zope.ComponentArchitecture"
- name="getNextServiceManager"
- implementation=".hooks.getNextServiceManager_hook" />
-
</zopeConfigure>
=== Removed File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/hooks.py ===