[Zope3-checkins] CVS: Zope3/src/zope/app/services - service.py:1.30.6.1

Jim Fulton cvs-admin at zope.org
Tue Nov 11 12:28:24 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv28715/src/zope/app/services

Modified Files:
      Tag: adaptergeddon-branch
	service.py 
Log Message:
Changed local site managers (aka service managers) to have next and
subSites attributes.  Now local service managers are linked up to make
it easier to navigate related sites.


=== Zope3/src/zope/app/services/service.py 1.30 => 1.30.6.1 ===
--- Zope3/src/zope/app/services/service.py:1.30	Sun Sep 21 13:33:00 2003
+++ Zope3/src/zope/app/services/service.py	Tue Nov 11 12:27:53 2003
@@ -28,6 +28,7 @@
 
 import sys
 
+from zope.app import zapi
 from zodb.code.module import PersistentModuleRegistry
 
 from zope.interface import implements
@@ -54,7 +55,10 @@
 from zope.app.container.contained import Contained
 from zope.app.container.btree import BTreeContainer
 
-class ServiceManager(BTreeContainer,
+from zope.app.interfaces.traversing import IContainmentRoot
+from zope.app.interfaces.services.service import ISite
+
+class SiteManager(BTreeContainer,
                      PersistentModuleRegistry,
                      NameComponentRegistry,
                      ):
@@ -67,8 +71,30 @@
         BTreeContainer.__init__(self)
         PersistentModuleRegistry.__init__(self)
         NameComponentRegistry.__init__(self)
+        self.subSites = ()
+        self._setNext(site)
         self['default'] = SiteManagementFolder()
 
+    def _setNext(self, site):
+        """Find set the next service manager
+        """
+
+        while 1:
+            if IContainmentRoot.isImplementedBy(site):
+                # we're the root site, use the global sm
+                self.next = zapi.getServiceManager(None)
+                return
+            site = site.__parent__
+            if site is None:
+                raise TypeError("Not enough context information")
+            if ISite.isImplementedBy(site):
+                self.next = site.getSiteManager()
+                self.next.addSubsite(self)
+                return
+
+    def addSubsite(self, sub):
+        self.subSites += (sub, )
+
     def getServiceDefinitions(wrapped_self):
         "See IServiceService"
 
@@ -201,6 +227,7 @@
 
         return mod
 
+ServiceManager = SiteManager # Backward compat
 
 class ServiceRegistration(NamedComponentRegistration):
 




More information about the Zope3-Checkins mailing list