[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager - ServiceManager.py:1.1.2.7

Gary Poster garyposter@earthlink.net
Mon, 22 Apr 2002 15:03:51 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv31509/App/OFS/ServiceManager

Modified Files:
      Tag: Zope-3x-branch
	ServiceManager.py 
Log Message:
1. As per ZopeTop discussion, moved Addable out of ZMI into the Services folder, and turned it into a true service (this involved a lot of small changes, particularly in the folders and a number of tests) and gave it some hooks
2. used SteveA's ContextWrapper.ContextMethod to make the ServiceManager and Services placefully look up to parent placeful equivalents
3. Made Event into a more standard service, and gave it some hooks
4. Built the beginning of a placeful EventService (will need tests, and views, and EventChannels, and more meat; just wanted to check this in for now)
5. made it so you can't add an item to a folder with a blank string id, and updated the folder interface
6. some typos fixed here and there
7. a few more tests here and there

I'm checking this in then checking it out again to check my work; also tagged previous version as gary-service_update.



=== Zope3/lib/python/Zope/App/OFS/ServiceManager/ServiceManager.py 1.1.2.6 => 1.1.2.7 ===
 from Zope.Exceptions import NotFoundError, ZopeError
 from Zope.App.OFS.Folder.Folder import Folder
-from Zope.ContextWrapper import getinnercontext, Wrapper
+from Zope.ContextWrapper import getinnercontext, Wrapper, ContextMethod
 from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
 
 class ServiceManager(BTreeContainer):
@@ -37,11 +37,11 @@
         super(ServiceManager, self).__init__()
         
 
-    def getServiceDefinitions(self):
+    def getServiceDefinitions(wrapped_self):
         """ see IServiceService Interface """
         # Get the services defined here and above us, if any (as held
         # in a ServiceInterfaceService, presumably)
-        sm=getNextServiceManager(self)
+        sm=getNextServiceManager(wrapped_self)
         if sm is not None:
             serviceDefs=sm.getServiceDefinitions()
         else: serviceDefs={}
@@ -49,21 +49,25 @@
         # worrying about this further is pointless--it probably will be
         # an interface service evetually though...so this would be useful then:
         
-        serviceInterfaceServ=self.__bindings.get('ServiceInterfaceService')
+        serviceInterfaceServ=wrapped_self.__bindings.get('ServiceInterfaceService')
         if serviceInterfaceServ:
-            serviceDefs.update(dict(self.getObject(serviceInterfaceServ).objectItems()))
+            serviceDefs.update(dict(wrapped_self.getObject(serviceInterfaceServ).objectItems()))
         return serviceDefs
     
-    def getService(self, name):
+    getServiceDefinitions=ContextMethod(getServiceDefinitions)
+    
+    def getService(wrapped_self, name):
         """ see IServiceService Interface"""
         
-        service = self.__bindings.get(name)
+        service = wrapped_self.__bindings.get(name)
                 
         if service:
-            return Wrapper(self.getObject(service), self, name=name)
+            return Wrapper(wrapped_self.getObject(service), wrapped_self, name=name)
             # we don't need to check security, do we?
             
-        return getNextService(self, name)
+        return getNextService(wrapped_self, name)
+    
+    getService=ContextMethod(getService)
 
     def getBoundService(self, name):
         """ see IServiceManager Interface"""
@@ -91,6 +95,8 @@
         self.__bindings = self.__bindings
         
         self.__bindings[serviceName] = serviceComponentName
+    
+    bindService=ContextMethod(bindService) # needed because of call to getServiceDefinitions
 
     def unbindService(self, serviceName):
         """ see IServiceManager Interface """