[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - ServiceManager.py:1.8
Jeremy Hylton
jeremy@zope.com
Wed, 2 Oct 2002 18:15:28 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv32273/lib/python/Zope/App/OFS/Services/ServiceManager
Modified Files:
ServiceManager.py
Log Message:
Mixin PersistentModuleRegistry to ServiceManager.
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py:1.7 Thu Aug 1 14:42:12 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py Wed Oct 2 18:15:28 2002
@@ -11,7 +11,11 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""XXX I need a summary line.
+
+In addition, a ServiceManager acts as a registry for persistent
+modules. The Zope import hook uses the ServiceManager to search for
+modules.
$Id$
"""
@@ -40,12 +44,16 @@
from Package import Package
from IServiceManager import IServiceManager
-class ServiceManager(Persistent):
+from Persistence.Module import PersistentModuleRegistry
- __implements__ = IServiceManager, ISimpleReadContainer
+class ServiceManager(Persistent,
+ PersistentModuleRegistry):
- def __init__(self):
+ __implements__ = (IServiceManager, ISimpleReadContainer,
+ PersistentModuleRegistry.__implements__)
+ def __init__(self):
+ super(ServiceManager, self).__init__()
self.__bindings = {}
# Bindings is of the form:
#
@@ -298,3 +306,18 @@
return self.get(key) is not None
+ def findModule(self, name):
+ # override to pass call up to next service manager
+ mod = super(ServiceManager, self).findModule(name)
+ if mod is not None:
+ return mod
+
+ sm = getNextServiceManager(self)
+ try:
+ findModule = sm.findModule
+ except AttributeError:
+ # The only service manager that doesn't implement this
+ # interface is the global service manager. There is no
+ # direct way to ask if sm is the global service manager.
+ return None
+ return findModule(name)