[Zope3-checkins] CVS: Zope3/src/zope/app/rdb - __init__.py:1.22 gadflyda.py:1.6 metaconfigure.py:1.4 service.zcml:NONE

Mohan Chandra mchandra at zeomega.com
Fri Dec 19 11:53:48 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/rdb
In directory cvs.zope.org:/tmp/cvs-serv28838/src/zope/app/rdb

Modified Files:
	__init__.py gadflyda.py metaconfigure.py 
Removed Files:
	service.zcml 
Log Message:
Removal of Databaseconnection service 



=== Zope3/src/zope/app/rdb/__init__.py 1.21 => 1.22 ===
--- Zope3/src/zope/app/rdb/__init__.py:1.21	Tue Jul 22 06:05:51 2003
+++ Zope3/src/zope/app/rdb/__init__.py	Fri Dec 19 11:53:17 2003
@@ -32,14 +32,14 @@
 from zope.security.checker import NamesChecker
 
 from zope.interface import implements
-
+from zope.app import zapi
 from zope.app.interfaces.rdb import DatabaseException
-from zope.app.interfaces.rdb import IResultSet, ISQLCommand
+from zope.app.interfaces.rdb import IResultSet
 from zope.app.interfaces.rdb import IZopeConnection, IZopeCursor
-from zope.app.interfaces.rdb import IZopeDatabaseAdapter
+from zope.app.interfaces.rdb import IZopeDatabaseAdapter, ISQLCommand
 from zope.app.interfaces.rdb import IGlobalConnectionService
 
-from zope.app.component.nextservice import getNextService
+
 
 def sqlquote(x):
     """
@@ -102,25 +102,6 @@
         return cmp(len(self), len(other))
 
 
-class SQLCommand:
-    """A simple version of a SQL Command."""
-
-    implements(ISQLCommand)
-
-    def __init__(self, connection_name='', sql=''):
-        self.connectionName = connection_name
-        self.sql = sql
-
-    def getConnection(self):
-        'See ISQLCommand'
-        connection_service = getNextService(self, "SQLDatabaseConnections")
-        connection = connection_service.getConnection(self.connectionName)
-        return connection
-
-    def __call__(self):
-        return queryForResults(self.getConnection(), self.sql)
-
-
 class DatabaseAdapterError(Exception):
     pass
 
@@ -439,48 +420,6 @@
 
     return type('GeneratedRowClass', (Row,), klass_namespace)
 
-class GlobalConnectionService:
-
-    implements(IGlobalConnectionService)
-
-    def __init__(self):
-        self.__registry = {}
 
-    def getConnection(self, name):
-        """Returns a connection object by name."""
-        dbadapter = self.__registry[name]
-        if dbadapter is not None:
-            return dbadapter()
-        raise KeyError, name
-
-    def queryConnection(self, name, default=None):
-        """Returns a connection object by name or default."""
-        try:
-            return self.getConnection(name)
-        except KeyError:
-            return default
-
-    def getAvailableConnections(self):
-        """Returns the connections available from this connection service."""
-        return self.__registry.keys()
-
-    def provideConnection(self, name, connection):
-        """ Register a connection instance for site-wide use """
-        self.__registry[name] = connection
-
-    _clear = __init__
-
-connectionService = GlobalConnectionService()
-getConnection = connectionService.getConnection
-queryConnection = connectionService.queryConnection
-getAvailableConnections = connectionService.getAvailableConnections
-provideConnection = connectionService.provideConnection
-
-_clear         = connectionService._clear
-
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
-from zope.testing.cleanup import addCleanUp
-addCleanUp(_clear)
-del addCleanUp
 
 


=== Zope3/src/zope/app/rdb/gadflyda.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/rdb/gadflyda.py:1.5	Tue Aug 19 03:09:48 2003
+++ Zope3/src/zope/app/rdb/gadflyda.py	Fri Dec 19 11:53:17 2003
@@ -27,6 +27,9 @@
 class GadflyAdapter(ZopeDatabaseAdapter):
     """A Gadfly adapter for Zope3"""
 
+    # The registerable object needs to have a container
+    __name__ = __parent__ = None 
+    
     def _getGadflyRoot(self):
         # XXX: Need to write a configuration directive for setting this up
         # At the moment gadfly root is 'gadfly' under the instance home (which


=== Zope3/src/zope/app/rdb/metaconfigure.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/rdb/metaconfigure.py:1.3	Sun Aug 17 02:07:45 2003
+++ Zope3/src/zope/app/rdb/metaconfigure.py	Fri Dec 19 11:53:17 2003
@@ -15,8 +15,9 @@
 
 $Id$
 """
-from zope.component import getService
-from zope.app.services.servicenames import SQLDatabaseConnections
+from zope.app import zapi
+from zope.app.interfaces.rdb import IZopeDatabaseAdapter
+
 
 def connectionhandler(_context, name, component, dsn):
     connection = component(dsn)
@@ -24,7 +25,15 @@
             discriminator = ('provideConnection', name),
             callable = provideConnection,
             args = (name, connection) )
-
+    
 def provideConnection(name, connection):
-    getService(None, SQLDatabaseConnections).provideConnection(name, connection)
+    """ Registers a database connection
+    
+     Uses the Utility Service for registering
+    """
+    utilities = zapi.getService(None, zapi.servicenames.Utilities)
+    utilities.provideUtility(IZopeDatabaseAdapter, connection, name)
+
+
+    
 

=== Removed File Zope3/src/zope/app/rdb/service.zcml ===




More information about the Zope3-Checkins mailing list