[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IServiceService.py:1.1.2.8 Service.py:1.1.6.12 ServiceManagerContainer.py:1.1.2.4 __init__.py:1.1.6.19 hooks.py:1.1.2.23

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


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

Modified Files:
      Tag: Zope-3x-branch
	IServiceService.py Service.py ServiceManagerContainer.py 
	__init__.py hooks.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/ComponentArchitecture/IServiceService.py 1.1.2.7 => 1.1.2.8 ===
         ServiceService implimentation if the requested Service
         is not found.
+        
+        If none is found anywhere, raises ComponentLookupError
         """


=== Zope3/lib/python/Zope/ComponentArchitecture/Service.py 1.1.6.11 => 1.1.6.12 ===
 """
 
-from Zope.Exceptions import DuplicationError, NotFoundError
+from Zope.Exceptions import DuplicationError
 from IServiceService import IServiceService
 from IServiceManagerContainer import IServiceManagerContainer
 from Zope.ContextWrapper import getinnercontext
+from Exceptions import ComponentLookupError
 
 
 class UndefinedService(Exception):
@@ -72,7 +73,7 @@
         try:
             return self.__services[name]
         except KeyError:
-            return NotFoundError(name)
+            raise ComponentLookupError(name)
 
     def _clear(self):
         self.__init__()
@@ -88,6 +89,3 @@
 from Zope.Testing.CleanUp import addCleanUp
 addCleanUp(_clear)
 del addCleanUp
-
-def getGlobalServiceManager():
-    return serviceManager


=== Zope3/lib/python/Zope/ComponentArchitecture/ServiceManagerContainer.py 1.1.2.3 => 1.1.2.4 ===
 from IServiceService import IServiceService
 from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
-from Zope.ContextWrapper import Wrapper
+from Zope.ContextWrapper import Wrapper, ContextMethod
 
 _marker = object()
 
@@ -37,16 +37,18 @@
 
         return hasattr(self, '_ServiceManagerContainer__sm')
 
-    def getServiceManager(self, default=_marker):
+    def getServiceManager(wrapped_self, default=_marker):
         '''See interface IServiceManagerContainer'''
 
         try:
-            return Wrapper(self.__sm, self) # no name?
+            return Wrapper(wrapped_self.__sm, wrapped_self) # no name
         except AttributeError:
             if default is _marker:
                 raise ComponentLookupError
             else:
                 return default
+    
+    getServiceManager=ContextMethod(getServiceManager)
 
     def setServiceManager(self, sm):
         '''See interface IServiceManagerContainer'''


=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.1.6.18 => 1.1.6.19 ===
 from hooks import provideFactory, createObject
 from hooks import getServiceManager, getNextServiceManager, \
-    getService, getServiceDefinitions, getNextService
+    getService, getServiceDefinitions, getNextService, \
+    getGlobalServiceManager
 from Service import defineService, provideService
-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/hooks.py 1.1.2.22 => 1.1.2.23 ===
     return getNextService_hook(context, name)
 
+def getGlobalServiceManager():
+    return getGlobalServiceManager_hook()
+
 # default hooks
 
 def getServiceManager_hook(context):
@@ -79,6 +82,9 @@
     if sm:
         return sm.getService(name)
     return None
+
+def getGlobalServiceManager_hook(): # this hook is really only useful to change for testing
+    return serviceManager
 
 from IToIRegistry import IToIRegistry, IRegistry