[Zodb-checkins] SVN: ZODB/branches/pycon-multidb/src/ZODB/Connection.py - Completed (low level) multi-database support. See testmultidb.py

Christian Theune ct at gocept.com
Sat Mar 19 17:09:14 EST 2005


Log message for revision 29582:
   - Completed (low level) multi-database support. See testmultidb.py 
  
  

Changed:
  U   ZODB/branches/pycon-multidb/src/ZODB/Connection.py

-=-
Modified: ZODB/branches/pycon-multidb/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/pycon-multidb/src/ZODB/Connection.py	2005-03-19 21:22:20 UTC (rev 29581)
+++ ZODB/branches/pycon-multidb/src/ZODB/Connection.py	2005-03-19 22:09:14 UTC (rev 29582)
@@ -257,8 +257,13 @@
 
     def get_connection(self, database_name):
         """Return a Connection for the named database."""
-        # XXX implement this
-        return
+        connection = self.connections.get(database_name)
+        if connection is None:
+            new_con = self._db.databases[database_name].open()
+            self.connections.update(new_con.connections)
+            new_con.connections = self.connections
+            connection = new_con
+        return connection
 
     def getTransaction(self):
         """Get the current transaction for this connection.
@@ -453,6 +458,9 @@
         self._reader = ConnectionObjectReader(self, self._cache,
                                               self._db.classFactory)
 
+        # Multi-database support
+        self.connections = {self._db.database_name: self}
+
     def _resetCache(self):
         """Creates a new cache, discarding the old one.
 



More information about the Zodb-checkins mailing list