Commit 68ef2b04 authored by Jim Fulton's avatar Jim Fulton

Fixed a bug in basic multi-database support. get_connection needs to

pass optional open arguments to secondary databases.
parent 1d63f327
...@@ -300,7 +300,10 @@ class Connection(ExportImport, object): ...@@ -300,7 +300,10 @@ class Connection(ExportImport, object):
"""Return a Connection for the named database.""" """Return a Connection for the named database."""
connection = self.connections.get(database_name) connection = self.connections.get(database_name)
if connection is None: if connection is None:
new_con = self._db.databases[database_name].open() new_con = self._db.databases[database_name].open(
transaction_manager=self.transaction_manager,
mvcc=self._mvcc, version=self._version, synch=self._synch,
)
self.connections.update(new_con.connections) self.connections.update(new_con.connections)
new_con.connections = self.connections new_con.connections = self.connections
connection = new_con connection = new_con
......
...@@ -94,7 +94,9 @@ Because that failed, db.databases wasn't changed: ...@@ -94,7 +94,9 @@ Because that failed, db.databases wasn't changed:
You can (still) get a connection to a database this way: You can (still) get a connection to a database this way:
>>> cn = db.open() >>> import transaction
>>> tm = transaction.TransactionManager()
>>> cn = db.open(transaction_manager=tm)
>>> cn # doctest: +ELLIPSIS >>> cn # doctest: +ELLIPSIS
<Connection at ...> <Connection at ...>
...@@ -111,6 +113,11 @@ thread/transaction/context ...): ...@@ -111,6 +113,11 @@ thread/transaction/context ...):
>>> cn2 # doctest: +ELLIPSIS >>> cn2 # doctest: +ELLIPSIS
<Connection at ...> <Connection at ...>
The second connection gets the same transaction manager as the first:
>>> cn2.transaction_manager is tm
True
Now there are two connections in that collection: Now there are two connections in that collection:
>>> cn2.connections is cn.connections >>> cn2.connections is cn.connections
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment