[Zope3-checkins] CVS: Zope3/src/zope/component - service.py:1.5.2.1

Jim Fulton cvs-admin at zope.org
Tue Nov 11 11:04:43 EST 2003


Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv15174

Modified Files:
      Tag: adaptergeddon-branch
	service.py 
Log Message:
made global service managers picklable (as globals).


=== Zope3/src/zope/component/service.py 1.5 => 1.5.2.1 ===
--- Zope3/src/zope/component/service.py:1.5	Mon Oct  6 18:08:54 2003
+++ Zope3/src/zope/component/service.py	Tue Nov 11 11:04:12 2003
@@ -50,14 +50,20 @@
        the required interface
     """
 
-class GlobalServiceManager:
+class GlobalServiceManager(object):
     """service manager"""
 
     implements(IGlobalServiceManager)
 
-    def __init__(self):
+    def __init__(self, name=None, module=None):
         self.__defs     = {}
         self.__services = {}
+        self.__name__ = name
+        self.__module__ = module
+
+    def __reduce__(self):
+        # Global service managers are pickled as global objects
+        return self.__name__
 
     def defineService(self, name, interface):
         """see IGlobalServiceManager interface"""
@@ -105,13 +111,12 @@
     _clear = __init__
 
 
-serviceManager = GlobalServiceManager() # the global service manager instance
-defineService = serviceManager.defineService
-
+# the global service manager instance
+serviceManager = GlobalServiceManager('serviceManager', __name__)
 
-_clear         = serviceManager._clear
+defineService = serviceManager.defineService
 
 # Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
 from zope.testing.cleanup import addCleanUp
-addCleanUp(_clear)
+addCleanUp(serviceManager._clear)
 del addCleanUp




More information about the Zope3-Checkins mailing list