[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests - PlacefulSetup.py:1.3

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/tests
In directory cvs.zope.org:/tmp/cvs-serv17483/lib/python/Zope/App/OFS/Services/ServiceManager/tests

Modified Files:
	PlacefulSetup.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/tests/PlacefulSetup.py 1.2 => 1.3 ===
         # set up placeful hooks, saving originals for tearDown
         from Zope import ComponentArchitecture as CA
-        self.__old_getServiceManager_hook=CA.getServiceManager_hook
-        self.__old_getNextServiceManager_hook=CA.getNextServiceManager_hook
-        from Zope.App.OFS.Services.ServiceManager import hooks
-        CA.getServiceManager_hook=hooks.getServiceManager_hook
-        CA.getNextServiceManager_hook=hooks.getNextServiceManager_hook
+        self.__old_getServiceManager_hook = CA.getServiceManager_hook
+        self.__old_getNextServiceManager_hook = CA.getNextServiceManager_hook
+        from Zope.App.ComponentArchitecture import hooks
+        CA.getServiceManager_hook = hooks.getServiceManager_hook
+        CA.getNextServiceManager_hook = hooks.getNextServiceManager_hook
 
     def buildFolders(self):
         # set up a reasonably complex folder structure
@@ -44,56 +44,57 @@
         from Zope.App.OFS.Content.Folder.RootFolder import RootFolder
         from Zope.Proxy.ContextWrapper import ContextWrapper
         # top
-        self.rootFolder=RootFolder()
+        self.rootFolder = RootFolder()
         # level 1
-        self.folder1=Folder()
-        self.rootFolder.setObject("folder1",self.folder1)
-        self.folder1=ContextWrapper(self.folder1, self.rootFolder,
-             name="folder1")
-        self.folder2=Folder()
-        self.rootFolder.setObject("folder2",self.folder2)
-        self.folder2=ContextWrapper(self.folder2, self.rootFolder,
-             name="folder2")
+        self.folder1 = Folder()
+        self.rootFolder.setObject("folder1", self.folder1)
+        self.folder1 = ContextWrapper(self.folder1, self.rootFolder,
+             name = "folder1")
+        self.folder2 = Folder()
+        self.rootFolder.setObject("folder2", self.folder2)
+        self.folder2 = ContextWrapper(self.folder2, self.rootFolder,
+             name = "folder2")
         # level 2
-        self.folder1_1=Folder()
-        self.folder1.setObject("folder1_1",self.folder1_1)
-        self.folder1_1=ContextWrapper(self.folder1_1, self.folder1,
-             name="folder1_1")
-        self.folder1_2=Folder()
-        self.folder1.setObject("folder1_2",self.folder1_2)
-        self.folder1_2=ContextWrapper(self.folder1_2, self.folder1,
-             name="folder1_2")
-        self.folder2_1=Folder()
-        self.folder2.setObject("folder2_1",self.folder2_1)
-        self.folder2_1=ContextWrapper(self.folder2_1, self.folder2,
-             name="folder2_1")
+        self.folder1_1 = Folder()
+        self.folder1.setObject("folder1_1", self.folder1_1)
+        self.folder1_1 = ContextWrapper(self.folder1_1, self.folder1,
+             name = "folder1_1")
+        self.folder1_2 = Folder()
+        self.folder1.setObject("folder1_2", self.folder1_2)
+        self.folder1_2 = ContextWrapper(self.folder1_2, self.folder1,
+             name = "folder1_2")
+        self.folder2_1 = Folder()
+        self.folder2.setObject("folder2_1", self.folder2_1)
+        self.folder2_1 = ContextWrapper(self.folder2_1, self.folder2,
+             name = "folder2_1")
         # level 3
-        self.folder1_1_1=Folder()
-        self.folder1_1.setObject("folder1_1_1",self.folder1_1_1)
-        self.folder1_1_1=ContextWrapper(self.folder1_1_1, self.folder1_1,
-             name="folder1_1_1")
-        self.folder1_1_2=Folder()
-        self.folder1_1.setObject("folder1_1_2",self.folder1_1_2)
-        self.folder1_1_2=ContextWrapper(self.folder1_1_2, self.folder1_1,
-             name="folder1_1_2")
-        self.folder1_2_1=Folder()
-        self.folder1_2.setObject("folder1_2_1",self.folder1_2_1)
-        self.folder1_2_1=ContextWrapper(self.folder1_2_1, self.folder1_2,
-             name="folder1_2_1")
-        self.folder2_1_1=Folder()
-        self.folder2_1.setObject("folder2_1_1",self.folder2_1_1)
-        self.folder2_1_1=ContextWrapper(self.folder2_1_1, self.folder2_1,
-             name="folder2_1_1")
+        self.folder1_1_1 = Folder()
+        self.folder1_1.setObject("folder1_1_1", self.folder1_1_1)
+        self.folder1_1_1 = ContextWrapper(self.folder1_1_1, self.folder1_1,
+             name = "folder1_1_1")
+        self.folder1_1_2 = Folder()
+        self.folder1_1.setObject("folder1_1_2", self.folder1_1_2)
+        self.folder1_1_2 = ContextWrapper(self.folder1_1_2, self.folder1_1,
+             name = "folder1_1_2")
+        self.folder1_2_1 = Folder()
+        self.folder1_2.setObject("folder1_2_1", self.folder1_2_1)
+        self.folder1_2_1 = ContextWrapper(self.folder1_2_1, self.folder1_2,
+             name = "folder1_2_1")
+        self.folder2_1_1 = Folder()
+        self.folder2_1.setObject("folder2_1_1", self.folder2_1_1)
+        self.folder2_1_1 = ContextWrapper(self.folder2_1_1, self.folder2_1,
+             name = "folder2_1_1")
 
-    def createServiceManager(self, folder=None):
-        if folder is None: folder=self.rootFolder
-        from Zope.App.OFS.Services.ServiceManager.ServiceManager import ServiceManager
+    def createServiceManager(self, folder = None):
+        if folder is None: folder = self.rootFolder
+        from Zope.App.OFS.Services.ServiceManager.ServiceManager \
+             import ServiceManager
         folder.setServiceManager(ServiceManager())
 
     def tearDown(self):
         # clean up folders and placeful service managers and services too?
         from Zope import ComponentArchitecture as CA
-        CA.getServiceManager_hook=self.__old_getServiceManager_hook
-        CA.getNextServiceManager_hook=self.__old_getNextServiceManager_hook
+        CA.getServiceManager_hook = self.__old_getServiceManager_hook
+        CA.getNextServiceManager_hook = self.__old_getNextServiceManager_hook
         PlacelessSetup.tearDown(self)