[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - ConfigurationManager.py:1.3 IConfigurationManager.py:1.4 IServiceConfiguration.py:1.5 IServiceManager.py:1.7 ServiceConfiguration.py:1.5 ServiceManager.py:1.14 configure.zcml:1.9 IServiceAdding.py:NONE

Marius Gedminas mgedmin@codeworks.lt
Thu, 12 Dec 2002 06:33:03 -0500


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

Modified Files:
	ConfigurationManager.py IConfigurationManager.py 
	IServiceConfiguration.py IServiceManager.py 
	ServiceConfiguration.py ServiceManager.py configure.zcml 
Removed Files:
	IServiceAdding.py 
Log Message:
Merge named-component-configuration-branch



=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ConfigurationManager.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ConfigurationManager.py:1.2	Sat Nov 30 13:39:16 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ConfigurationManager.py	Thu Dec 12 06:32:32 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
 $Id$
@@ -19,14 +19,18 @@
 
 from Persistence import Persistent
 from IConfigurationManager import IConfigurationManager
+from Zope.App.OFS.Container.IDeleteNotifiable import IDeleteNotifiable
+from Zope.App.OFS.Container.IZopeContainer import IZopeWriteContainer
+from Zope.ComponentArchitecture import getAdapter
+
 
 class ConfigurationManager(Persistent):
     """Configuration manager
 
     Manages configurations within a package.
     """
-    
-    __implements__ = IConfigurationManager
+
+    __implements__ = IConfigurationManager, IDeleteNotifiable
 
     def __init__(self):
         self._data = ()
@@ -49,7 +53,7 @@
     def __contains__(self, key):
         "See Interface.Common.Mapping.IReadMapping"
         return self.get(key) is not None
-    
+
 
     def keys(self):
         "See Interface.Common.Mapping.IEnumerableMapping"
@@ -58,7 +62,7 @@
     def values(self):
         "See Interface.Common.Mapping.IEnumerableMapping"
         return [v for k, v in self._data]
-    
+
     def items(self):
         "See Interface.Common.Mapping.IEnumerableMapping"
         return self._data
@@ -73,7 +77,7 @@
         key = str(self._next)
         self._data += ((key, object), )
         return key
-        
+
     def __delitem__(self, key):
         "See Zope.App.OFS.Container.IContainer.IWriteContainer"
         if key not in self:
@@ -113,7 +117,7 @@
                 j = max(i + direction, 0)
                 while j in indexes:
                     j += 1
-                
+
                 indexes[j] = item
 
         # Fill in the rest where there's room.
@@ -134,7 +138,12 @@
 
     def moveDown(self, names):
         self._moveUpOrDown(names, 1)
-        
+
+    def manage_beforeDelete(self, object, container):
+        assert object == self
+        container = getAdapter(object, IZopeWriteContainer)
+        for k, v in self._data:
+            del container[k]
 
 
 __doc__ = ConfigurationManager.__doc__  + __doc__


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IConfigurationManager.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IConfigurationManager.py:1.3	Sun Dec  1 05:28:22 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IConfigurationManager.py	Thu Dec 12 06:32:32 2002
@@ -21,7 +21,7 @@
 class IOrderedContainer(Interface):
     """Container with items that can be rearranged.
     """
-    
+
     # Yes, maybe this should be in the container package, but, we are
     # likely to come up with a better general ordering interface, so
     # we'll leave this one here for now.


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceConfiguration.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceConfiguration.py:1.4	Thu Dec  5 12:00:44 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceConfiguration.py	Thu Dec 12 06:32:32 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
 $Id$
@@ -17,17 +17,17 @@
 
 from Interface.Attribute import Attribute
 from Zope.App.OFS.Services.ConfigurationInterfaces \
-     import IComponentConfiguration
+     import INamedComponentConfiguration
 
-class IServiceConfiguration(IComponentConfiguration):
+class IServiceConfiguration(INamedComponentConfiguration):
     """Service Configuration
 
     Service configurations are dependent on the components that they
     configure. They register themselves as component dependents.
-    
+
+    The name of a service configuration is used to determine the service
+    type.
     """
 
-    serviceType = Attribute("The service type id")
 
 __doc__ = IServiceConfiguration.__doc__ + __doc__
-


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceManager.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceManager.py:1.6	Mon Dec  9 10:16:35 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceManager.py	Thu Dec 12 06:32:32 2002
@@ -2,27 +2,27 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
 
 $Id$
 """
 from Zope.ComponentArchitecture.IServiceService import IServiceService
-from Zope.App.OFS.Services.ConfigurationInterfaces import IConfigurable
+from Zope.App.OFS.Services.ConfigurationInterfaces import INameConfigurable
 from IComponentManager import IComponentManager
 from Interface.Attribute import Attribute
 
-class IServiceManager(IServiceService, IComponentManager, IConfigurable):
+class IServiceManager(IServiceService, IComponentManager, INameConfigurable):
     """Service Managers act as containers for Services.
-    
+
     If a Service Manager is asked for a service, it checks for those it
     contains before using a context based lookup to find another service
     manager to delegate to.  If no other service manager is found they defer
@@ -31,14 +31,6 @@
     """
 
     Packages = Attribute("""Package container""")
-    
-    def queryConfigurations(service_type):
-        """Return an IConfigurationRegistry for a service type
-        """
-
-    def createConfigurations(service_type):
-        """Create and return an IConfigurationRegistry for a service type
-        """
 
     def getBoundService(name):
         """Retrieve a bound service implementation.
@@ -48,7 +40,3 @@
 
         None is returned if the named service isn't bound locally.
         """
-
-    def getBoundServiceTypes():
-        """Get a sequence of the bound service types"""
-


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceConfiguration.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceConfiguration.py:1.4	Thu Dec  5 12:00:44 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceConfiguration.py	Thu Dec 12 06:32:32 2002
@@ -2,53 +2,60 @@
 #
 # Copyright (c) 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
 $Id$
 """
 
 from IServiceConfiguration import IServiceConfiguration
-from Zope.App.OFS.Services.Configuration import ConfigurationStatusProperty
 from IBindingAware import IBindingAware
-from Zope.App.OFS.Services.Configuration import ComponentConfiguration
+from Zope.App.OFS.Services.Configuration import ConfigurationStatusProperty
+from Zope.App.OFS.Services.Configuration import NamedComponentConfiguration
 from Zope.ContextWrapper import ContextMethod
+from Zope.ComponentArchitecture import getServiceManager
+
+class ServiceConfiguration(NamedComponentConfiguration):
 
-class ServiceConfiguration(ComponentConfiguration):
     __doc__ = IServiceConfiguration.__doc__
-    
+
     __implements__ = (IServiceConfiguration,
-                      ComponentConfiguration.__implements__)
+                      NamedComponentConfiguration.__implements__)
 
     status = ConfigurationStatusProperty('Services')
 
-    def __init__(self, service_type, *args, **kw):
-        self.serviceType = service_type
+    label = "Service"
+
+    def __init__(self, *args, **kw):
         super(ServiceConfiguration, self).__init__(*args, **kw)
 
-    ############################################################
+    def getInterface(self):
+        service_manager = getServiceManager(self)
+        return service_manager.getInterfaceFor(self.name)
+
+    getInterface = ContextMethod(getInterface)
 
     def activated(self):
         service = self.getComponent()
         if IBindingAware.isImplementedBy(service):
-            service.bound(self.serviceType)
+            service.bound(self.name)
 
     activated = ContextMethod(activated)
 
     def deactivated(self):
         service = self.getComponent()
         if IBindingAware.isImplementedBy(service):
-            service.unbound(self.serviceType)
+            service.unbound(self.name)
 
     deactivated = ContextMethod(deactivated)
-    
+
 __doc__ = ServiceConfiguration.__doc__  + __doc__
 
-            
+


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py 1.13 => 1.14 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py:1.13	Mon Dec  9 10:22:20 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py	Thu Dec 12 06:32:32 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """XXX I need a summary line.
 
@@ -44,6 +44,7 @@
 from IServiceManager import IServiceManager
 
 from Zope.App.OFS.Services.Configuration import ConfigurationRegistry
+from Zope.App.OFS.Services.Configuration import NameConfigurable
 
 from Persistence.Module import PersistentModuleRegistry
 from Persistence.Module import PersistentModule
@@ -53,20 +54,16 @@
 ModuleType = ModuleType, PersistentModule
 
 
-class ServiceManager(PersistentModuleRegistry):
+class ServiceManager(PersistentModuleRegistry, NameConfigurable):
 
     __implements__ = (IServiceManager, ISimpleReadContainer,
                       PersistentModuleRegistry.__implements__,
+                      NameConfigurable.__implements__,
                       INameResolver)
 
     def __init__(self):
         super(ServiceManager, self).__init__()
-
-        self.__bindings = {}
-        # Bindings is of the form:
-        #
-        # {service_type -> ConfigurationRegistry}
-
+        NameConfigurable.__init__(self)
         self.Packages = Packages()
 
 
@@ -106,13 +103,13 @@
             return self # We are the service service
 
         if not getattr(self, '_v_calling', 0):
-            
+
             self._v_calling = 1
             try:
                 service = self.getBoundService(name)
                 if service is not None:
                     return service
-                    
+
             finally:
                 self._v_calling = 0
 
@@ -131,31 +128,6 @@
 
     getInterfaceFor = ContextMethod(getInterfaceFor)
 
-    def queryConfigurationsFor(self, configuration, default=None):
-        return self.queryConfigurations(configuration.serviceType, default)
-
-    queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
-
-    def queryConfigurations(self, service_type, default=None):
-        registry = self.__bindings.get(service_type, default)
-        return ContextWrapper(registry, self)
-
-    queryConfigurations = ContextMethod(queryConfigurations)
-        
-
-    def createConfigurationsFor(self, configuration):
-        return self.createConfigurations(configuration.serviceType)
-
-    createConfigurationsFor = ContextMethod(createConfigurationsFor)
-
-    def createConfigurations(self, service_type):
-        registry = ConfigurationRegistry()
-        self.__bindings[service_type] = registry
-        self._p_changed = 1
-        return registry
-
-    createConfigurations = ContextMethod(createConfigurations)
-
     def getBoundService(self, name):
         "See Zope.App.OFS.Services.ServiceManager.IServiceManager."
 
@@ -165,17 +137,11 @@
             if configuration is not None:
                 service = configuration.getComponent()
                 return service
-            
+
         return None
 
     getBoundService = ContextMethod(getBoundService)
 
-    def getBoundServiceTypes(self):
-        "See "
-        "Zope.App.OFS.Services.ServiceManager.IServiceManager.IServiceManager"
-        
-        return  self.__bindings.keys()
-
     ############################################################
     # Implementation methods for interface
     # Zope.App.OFS.Services.ServiceManager.IComponentManager.
@@ -208,7 +174,7 @@
         if key == 'Packages':
             return self.Packages
 
-        directives = self.__bindings.get(key)
+        directives = self.queryConfigurations(key)
         if directives and directives[0] is not None:
             return self.queryService(key, default)
 
@@ -222,11 +188,11 @@
         return self.get(key) is not None
 
     def findModule(self, name):
-        # override to pass call up to next service manager 
+        # override to pass call up to next service manager
         mod = super(ServiceManager, removeAllProxies(self)).findModule(name)
         if mod is not None:
             return mod
-        
+
         sm = getNextServiceManager(self)
         try:
             findModule = sm.findModule
@@ -252,7 +218,7 @@
     __import = ContextMethod(__import)
 
     def resolve(self, name):
-        
+
         name = name.strip()
 
         if name.endswith('.') or name.endswith('+'):


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml 1.8 => 1.9 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml:1.8	Sun Dec  1 05:28:22 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/configure.zcml	Thu Dec 12 06:32:32 2002
@@ -45,17 +45,20 @@
         interface="Zope.App.OFS.Container.IContainer.IWriteContainer" />
     <require
         permission="Zope.ManageServices"
-    	interface=".IConfigurationManager.IOrderedContainer" />
-    <factory 
-        id = "Zope.App.OFS.Services.ServiceManager.ConfigurationManager" 
-	permission = "Zope.ManageServices"
-	title = "Configuration Manager" />
+        interface=".IConfigurationManager.IOrderedContainer" />
+    <require
+        permission="Zope.ManageServices"
+        interface="Zope.App.OFS.Container.IDeleteNotifiable." />
+    <factory
+        id = "Zope.App.OFS.Services.ServiceManager.ConfigurationManager"
+        permission = "Zope.ManageServices"
+        title = "Configuration Manager" />
   </content>
 
   <content class=".Module.Manager.">
-    <require 
+    <require
         permission="Zope.ManageCode"
-	interface="Persistence.IPersistentModuleManager." />
+        interface="Persistence.IPersistentModuleManager." />
     <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
    </content>
 
@@ -78,7 +81,7 @@
         />
 
   </content>
-  
+
   <include package="Zope.App.OFS.Services.ServiceManager.Browser" />
 
 </zopeConfigure>

=== Removed File Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/IServiceAdding.py ===