[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services - Configuration.py:1.5 ConfigurationInterfaces.py:1.7

Marius Gedminas mgedmin@codeworks.lt
Thu, 12 Dec 2002 10:28:47 -0500


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

Modified Files:
	Configuration.py ConfigurationInterfaces.py 
Log Message:
Caching service now uses the new configuration infrastructure
Added invalidateAll to Zope.App.Caching.ICache



=== Zope3/lib/python/Zope/App/OFS/Services/Configuration.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/OFS/Services/Configuration.py:1.4	Thu Dec 12 06:32:30 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Configuration.py	Thu Dec 12 10:28:16 2002
@@ -373,22 +373,26 @@
         self._bindings = {}
 
     def queryConfigurationsFor(self, cfg, default=None):
+        """See Zope.App.OFS.Services.ConfigurationInterfaces.IConfigurable"""
         return self.queryConfigurations(cfg.name, default)
 
     queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
 
     def queryConfigurations(self, name, default=None):
+        """See Zope.App.OFS.Services.ConfigurationInterfaces.INameConfigurable"""
         registry = self._bindings.get(name, default)
         return ContextWrapper(registry, self)
 
     queryConfigurations = ContextMethod(queryConfigurations)
 
     def createConfigurationsFor(self, cfg):
+        """See Zope.App.OFS.Services.ConfigurationInterfaces.IConfigurable"""
         return self.createConfigurations(cfg.name)
 
     createConfigurationsFor = ContextMethod(createConfigurationsFor)
 
     def createConfigurations(self, name):
+        """See Zope.App.OFS.Services.ConfigurationInterfaces.INameConfigurable"""
         try:
             registry = self._bindings[name]
         except KeyError:
@@ -399,5 +403,17 @@
     createConfigurations = ContextMethod(createConfigurations)
 
     def listConfigurationNames(self):
+        """See Zope.App.OFS.Services.ConfigurationInterfaces.INameConfigurable"""
         return filter(self._bindings.get, self._bindings.keys())
+
+    def queryActiveComponent(self, name, default=None):
+        """See Zope.App.OFS.Services.ConfigurationInterfaces.INameConfigurable"""
+        registry = self.queryConfigurations(name)
+        if registry:
+            configuration = registry.active()
+            if configuration is not None:
+                return configuration.getComponent()
+        return default
+
+    queryActiveComponent = ContextMethod(queryActiveComponent)
 


=== Zope3/lib/python/Zope/App/OFS/Services/ConfigurationInterfaces.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConfigurationInterfaces.py:1.6	Thu Dec 12 06:32:30 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConfigurationInterfaces.py	Thu Dec 12 10:28:16 2002
@@ -221,9 +221,8 @@
         """Return a list of all registered configuration names
         """
 
-    # XXX It might be useful to abstract out common parts from
-    # ServiceManager.getBoundService and ConnectionService.getConnection
-    # into a method declared in INameConfigurable.  That would also mean that
-    # INameConfigurable relies on configurations implementing
-    # INamedComponentConfiguration, while now it is sufficient for a
-    # configuration to have a name attribute.
+    def queryActiveComponent(name, default=None):
+        """Finds the configuration registry for a given name, checks if it has
+        an active configuration, and if so, returns its component.  Otherwise
+        returns default.
+        """