[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ConnectionService - ConnectionConfiguration.py:1.1.2.1 ConnectionService.py:1.6.2.1 IConnectionConfiguration.py:1.1.2.1 IConnectionManager.py:1.2.2.1 configure.zcml:1.5.2.1
Marius Gedminas
mgedmin@codeworks.lt
Tue, 10 Dec 2002 14:16:32 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ConnectionService
In directory cvs.zope.org:/tmp/cvs-serv28246/lib/python/Zope/App/OFS/Services/ConnectionService
Modified Files:
Tag: named-component-configuration-branch
ConnectionConfiguration.py ConnectionService.py
IConnectionConfiguration.py IConnectionManager.py
configure.zcml
Log Message:
Refactoring of configuration views:
- new interfaces INamedComponentConfiguration, INameConfigurable,
implemented in NamedComponentConfiguration, NameConfigurable, simplify
the case where configurations are identified by a name (service types,
connections, caches, queries, etc)
- common views for INamedComponentConfiguration, INameConfigurable
- refactored ServiceManager and ConnectionService to take advantage of the
new infrastructure
- incidentally wrote several unit tests for configuration classes
- removed caching from ComponentConnection.getComponent; this exposed a bug
in LocalEventService tests
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionConfiguration.py 1.1 => 1.1.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionConfiguration.py:1.1 Mon Dec 9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionConfiguration.py Tue Dec 10 14:16:00 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.
-#
+#
##############################################################################
"""A configuration for a database adapter.
@@ -17,18 +17,19 @@
"""
from IConnectionConfiguration import IConnectionConfiguration
-from Zope.App.OFS.Services.Configuration import ComponentConfiguration
+from Zope.App.OFS.Services.Configuration import NamedComponentConfiguration
from Zope.App.OFS.Services.Configuration import ConfigurationStatusProperty
-class ConnectionConfiguration(ComponentConfiguration):
+class ConnectionConfiguration(NamedComponentConfiguration):
__doc__ = IConnectionConfiguration.__doc__
-
+
__implements__ = (IConnectionConfiguration,
- ComponentConfiguration.__implements__)
+ NamedComponentConfiguration.__implements__)
status = ConfigurationStatusProperty('SQLDatabaseConnections')
- def __init__(self, connection_name, *args, **kw):
- self.connectionName = connection_name
+ label = "Connection"
+
+ def __init__(self, *args, **kw):
super(ConnectionConfiguration, self).__init__(*args, **kw)
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionService.py 1.6 => 1.6.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionService.py:1.6 Mon Dec 9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionService.py Tue Dec 10 14:16:00 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,21 +19,21 @@
from Zope.ContextWrapper import ContextMethod
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.ComponentArchitecture.NextService import queryNextService
-from Zope.App.OFS.Annotation.IAttributeAnnotatable import IAttributeAnnotatable
from Zope.App.OFS.Services.ConfigurationInterfaces import IConfigurable
from Zope.App.OFS.Services.Configuration import ConfigurationRegistry
+from Zope.App.OFS.Services.Configuration import NameConfigurable
from IConnectionManager import IConnectionManager
-class ConnectionService(Persistent):
+class ConnectionService(Persistent, NameConfigurable):
__doc__ = IConnectionManager.__doc__
- __implements__ = IConnectionManager, IAttributeAnnotatable
+ __implements__ = IConnectionManager
def __init__(self):
super(ConnectionService, self).__init__()
- self.__bindings = {} # connectionName -> ConfigurationRegistry
+ NameConfigurable.__init__(self)
def getConnection(self, name):
@@ -49,50 +49,21 @@
getConnection = ContextMethod(getConnection)
def queryConnection(self, name, default=None):
- 'See Zope.App.RDB.IConnectionService.IConnectionService'
+ 'See Zope.App.RDB.IConnectionService.IConnectionService'
try:
return self.getConnection(name)
except KeyError:
return default
-
+
queryConnection = ContextMethod(queryConnection)
def getAvailableConnections(self):
'See Zope.App.RDB.IConnectionService.IConnectionService'
- connections = list(self.__bindings.keys())
+ connections = list(self.listConfigurationNames())
service = queryNextService(self, "SQLDatabaseConnections")
if service is not None:
connections.append(service.getAvailableConnections())
return connections
getAvailableConnections = ContextMethod(getAvailableConnections)
-
-
- def queryConfigurationsFor(self, cfg, default=None):
- 'See Zope.App.OFS.Services.ConfigurationInterfaces.IConfigurable'
- return self.queryConfigurations(cfg.connectionName)
-
- queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
-
- def queryConfigurations(self, name, default=None):
- 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.connectionName)
-
- createConfigurationsFor = ContextMethod(createConfigurationsFor)
-
- def createConfigurations(self, name):
- try:
- registry = self.__bindings[name]
- except KeyError:
- self.__bindings[name] = registry = ConfigurationRegistry()
- self._p_changed = 1
- return ContextWrapper(registry, self)
-
- createConfigurations = ContextMethod(createConfigurations)
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionConfiguration.py 1.1 => 1.1.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionConfiguration.py:1.1 Mon Dec 9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionConfiguration.py Tue Dec 10 14:16:00 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.
-#
+#
##############################################################################
"""A configuration for a database adapter.
@@ -18,15 +18,12 @@
from Zope.Schema import TextLine
from Zope.App.OFS.Services.ConfigurationInterfaces \
- import IComponentConfiguration
+ import INamedComponentConfiguration
-class IConnectionConfiguration(IComponentConfiguration):
+class IConnectionConfiguration(INamedComponentConfiguration):
"""Database Connection Configuration
Connection configurations are dependent on the database adapters that they
- configure. They register themselves as component dependents.
+ configure. They register themselves as component dependents.
"""
-
- connectionName = TextLine(title=u"Connection name",
- required=True)
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionManager.py 1.2 => 1.2.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionManager.py:1.2 Mon Dec 9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionManager.py Tue Dec 10 14:16:00 2002
@@ -2,26 +2,22 @@
#
# 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.App.RDB.IConnectionService import IConnectionService
-from Zope.App.OFS.Services.ConfigurationInterfaces import IConfigurable
+from Zope.App.OFS.Services.ConfigurationInterfaces import INameConfigurable
-class IConnectionManager(IConnectionService, IConfigurable):
+class IConnectionManager(IConnectionService, INameConfigurable):
"""A Connection Manager is a configurable connection service"""
- def queryConfigurations(connection_name):
- """Return an IConfigurationRegistry for a connection"""
-
- def createConfigurations(connection_name):
- """Create and return an IConfigurationRegistry a connection"""
+ pass
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/configure.zcml 1.5 => 1.5.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/configure.zcml:1.5 Mon Dec 9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/configure.zcml Tue Dec 10 14:16:00 2002
@@ -3,20 +3,22 @@
<content class=".ConnectionService.">
<factory id="ConnectionService" permission="Zope.ManageServices" />
- <require
- permission="Zope.View"
- interface="Zope.App.RDB.IConnectionService."
- attributes="queryConfigurations queryConfigurationsFor" />
- <require
- permission="Zope.ManageServices"
- interface="Zope.App.OFS.Container.IContainer." />
+ <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
+ <require
+ permission="Zope.View"
+ interface="Zope.App.RDB.IConnectionService."
+ attributes="queryConfigurations queryConfigurationsFor
+ listConfigurationNames" />
+ <require
+ permission="Zope.ManageServices"
+ interface="Zope.App.OFS.Container.IContainer." />
</content>
<content class=".ConnectionConfiguration.">
<require
permission="Zope.ManageServices"
interface=".IConnectionConfiguration."
- set_attributes="connectionName componentPath"
+ set_attributes="name componentPath"
set_schema=
"Zope.App.OFS.Services.ConfigurationInterfaces.IConfiguration" />
<require