[Zope3-checkins] CVS: Zope3/src/zodb - connection.py:1.12
Jeremy Hylton
jeremy@zope.com
Wed, 5 Mar 2003 17:42:54 -0500
Update of /cvs-repository/Zope3/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv25470/src/zodb
Modified Files:
connection.py
Log Message:
Raise TransactionError() when closing active connection.
Shane observes that this will almost always be an error, and it should
not pass silently.
=== Zope3/src/zodb/connection.py 1.11 => 1.12 ===
--- Zope3/src/zodb/connection.py:1.11 Wed Mar 5 17:14:30 2003
+++ Zope3/src/zodb/connection.py Wed Mar 5 17:42:53 2003
@@ -54,7 +54,7 @@
from zodb.utils import p64, u64, Set, z64
from transaction import get_transaction
-import transaction.interfaces
+from transaction.interfaces import IDataManager, IRollback, TransactionError
from persistence.cache import Cache
from persistence.interfaces import IPersistentDataManager
@@ -70,7 +70,7 @@
"""
__implements__ = (IAppConnection, IConnection, IPersistentDataManager,
- transaction.interfaces.IDataManager)
+ IDataManager)
def __init__(self, db, storage, version='', cache_size=400):
self._db = db
@@ -282,13 +282,9 @@
def close(self):
if self._txn is not None:
- # What should happen at this point? It's arguable that
- # close() should raise an error and force the application
- # to decide what should become of the transaction. It's
- # possible that multiple resources are involved in the
- # transaction.
- self._log.warn("connection closed while transaction active")
- self._txn.abort()
+ msg = "connection closed while transaction active"
+ self._log.warn(msg)
+ raise TransactionError(msg)
self._log.info("connection closed")
self._open = False
self._cache.incrgc()
@@ -521,9 +517,9 @@
# that has been changed since the rolledback transaction started.
# XXX Should it be possible to rollback() to the same savepoint
- # more than once?
+ # more than once? (Yes.)
- __implements__ = transaction.interfaces.IRollback
+ __implements__ = IRollback
def __init__(self, conn, tmp_undo):
self._conn = conn