[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - placefulsetup.py:1.18

Jim Fulton jim@zope.com
Mon, 31 Mar 2003 13:58:21 -0500


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

Modified Files:
	placefulsetup.py 
Log Message:
Added a convenience function for setting up a service for use in
tests.


=== Zope3/src/zope/app/services/tests/placefulsetup.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/services/tests/placefulsetup.py:1.17	Sun Mar 23 17:35:42 2003
+++ Zope3/src/zope/app/services/tests/placefulsetup.py	Mon Mar 31 13:58:21 2003
@@ -16,37 +16,37 @@
 Revision information:
 $Id$
 """
-from zope import component as CA
-from zope.component.adapter import provideAdapter
-from zope.component.view import provideView
-from zope.app.services.servicenames import HubIds, EventPublication, EventSubscription
-from zope.publisher.interfaces.browser import IBrowserPresentation
-
+from zope.app.attributeannotations import AttributeAnnotations
 from zope.app.browser.absoluteurl import SiteAbsoluteURL, AbsoluteURL
 from zope.app.component import hooks
 from zope.app.container.traversal import ContainerTraversable
+from zope.app.dependable import Dependable
+from zope.app.interfaces.annotation import IAnnotations
+from zope.app.interfaces.annotation import IAttributeAnnotatable
 from zope.app.interfaces.container import ISimpleReadContainer
 from zope.app.interfaces.content.folder import IRootFolder
+from zope.app.interfaces.dependable import IDependable
+from zope.app.interfaces.services.configuration import Active
+from zope.app.interfaces.services.configuration import IAttributeUseConfigurable
+from zope.app.interfaces.services.configuration import IUseConfiguration
+from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.interfaces.traversing import IPhysicallyLocatable
 from zope.app.interfaces.traversing import ITraverser, ITraversable
+from zope.app.services.configuration import UseConfiguration
+from zope.app.services.service import ServiceManager, ServiceConfiguration
+from zope.app.services.servicenames import EventPublication, EventSubscription
+from zope.app.services.servicenames import HubIds
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.app.traversing.namespace import etc, provideNamespaceHandler
 from zope.app.traversing.adapters import DefaultTraversable
-from zope.app.traversing.adapters import WrapperPhysicallyLocatable
 from zope.app.traversing.adapters import Traverser, RootPhysicallyLocatable
+from zope.app.traversing.adapters import WrapperPhysicallyLocatable
 from zope.app.traversing import traverse, getPath
-from zope.app.services.service import ServiceManager, ServiceConfiguration
-from zope.app.interfaces.services.configuration import Active
-from zope.app.interfaces.services.configuration import IAttributeUseConfigurable
-from zope.app.interfaces.services.configuration import IUseConfiguration
-from zope.app.services.configuration import UseConfiguration
-from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.interfaces.annotation import IAnnotations
-from zope.app.interfaces.dependable import IDependable
-from zope.app.interfaces.traversing import IContainmentRoot
-from zope.app.dependable import Dependable
+from zope.app.traversing.namespace import etc, provideNamespaceHandler
+from zope.component.adapter import provideAdapter
+from zope.component.view import provideView
+from zope import component as CA
+from zope.publisher.interfaces.browser import IBrowserPresentation
 
 class PlacefulSetup(PlacelessSetup):
 
@@ -211,8 +211,10 @@
         default.setObject("myObjectHub", self.getObjectHub())
 
         path = "%s/default/myEventService" % getPath(sm)
-        configuration = ServiceConfiguration(EventPublication, path, self.rootFolder)
-        default.getConfigurationManager().setObject("myEventServiceDir", configuration)
+        configuration = ServiceConfiguration(EventPublication, path,
+                                             self.rootFolder)
+        default.getConfigurationManager().setObject(
+            "myEventServiceDir", configuration)
         traverse(default.getConfigurationManager(), '1').status = Active
 
         configuration = ServiceConfiguration(EventSubscription, path,
@@ -223,9 +225,18 @@
 
         path = "%s/default/myObjectHub" % getPath(sm)
         configuration = ServiceConfiguration(HubIds, path, self.rootFolder)
-        default.getConfigurationManager().setObject("myHubIdsServiceDir", configuration)
+        default.getConfigurationManager().setObject("myHubIdsServiceDir",
+                                                    configuration)
         traverse(default.getConfigurationManager(), '3').status = Active
 
+def addService(servicemanager, name, service):
+    default = traverse(servicemanager, 'default')
+    default.setObject(name, service)
+    path = "%s/default/%s" % (getPath(servicemanager), name)
+    configuration = ServiceConfiguration(name, path, servicemanager)
+    default.getConfigurationManager().setObject("", configuration)
+    traverse(default.getConfigurationManager(), '1').status = Active
+    
 
 def createServiceManager(folder):
     folder.setServiceManager(ServiceManager())