[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ConnectionService - ConnectionConfiguration.py:1.2 ConnectionService.py:1.7 IConnectionConfiguration.py:1.2 configure.zcml:1.6 IConnectionAdding.py:NONE IConnectionManager.py:NONE
Marius Gedminas
mgedmin@codeworks.lt
Thu, 12 Dec 2002 06:33:02 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ConnectionService
In directory cvs.zope.org:/tmp/cvs-serv21266/lib/python/Zope/App/OFS/Services/ConnectionService
Modified Files:
ConnectionConfiguration.py ConnectionService.py
IConnectionConfiguration.py configure.zcml
Removed Files:
IConnectionAdding.py IConnectionManager.py
Log Message:
Merge named-component-configuration-branch
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionConfiguration.py 1.1 => 1.2 ===
--- 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 Thu Dec 12 06:32:31 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.7 ===
--- 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 Thu Dec 12 06:32:31 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,23 +17,25 @@
from Persistence import Persistent
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 IConnectionManager import IConnectionManager
+from Zope.App.OFS.Services.ConfigurationInterfaces import INameConfigurable
+from Zope.App.OFS.Services.Configuration import NameConfigurable
+from Zope.App.RDB.IConnectionService import IConnectionService
-class ConnectionService(Persistent):
+class ILocalConnectionService(IConnectionService, INameConfigurable):
+ """A local (placeful) connection service"""
- __doc__ = IConnectionManager.__doc__
- __implements__ = IConnectionManager, IAttributeAnnotatable
+class ConnectionService(Persistent, NameConfigurable):
+
+ __doc__ = ILocalConnectionService.__doc__
+
+ __implements__ = ILocalConnectionService
def __init__(self):
super(ConnectionService, self).__init__()
- self.__bindings = {} # connectionName -> ConfigurationRegistry
+ NameConfigurable.__init__(self)
def getConnection(self, name):
@@ -44,55 +46,34 @@
if configuration is not None:
adapter = configuration.getComponent()
return adapter()
+ service = queryNextService(self, "SQLDatabaseConnections")
+ if service is not None:
+ return service.getConnection(name)
raise KeyError, name
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 = {}
+ for name in self.listConfigurationNames():
+ registry = self.queryConfigurations(name)
+ if registry.active() is not None:
+ connections[name] = 0
service = queryNextService(self, "SQLDatabaseConnections")
if service is not None:
- connections.append(service.getAvailableConnections())
- return connections
+ for name in service.getAvailableConnections():
+ connections[name] = 0
+ return connections.keys()
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.2 ===
--- 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 Thu Dec 12 06:32:31 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/configure.zcml 1.5 => 1.6 ===
--- 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 Thu Dec 12 06:32:31 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
=== Removed File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionAdding.py ===
=== Removed File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionManager.py ===