summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-08-17 21:20:49 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-08-17 21:20:49 +0000
commitde1712a2116d80a6771ad5475277cc85e87179e2 (patch)
tree58f7f038b9259d01b91f6df36bdaf5305472bd03 /lib/sqlalchemy/engine
parent99b1bee20e20ddb74b1ade6b186f6f7a174968a2 (diff)
downloadsqlalchemy-de1712a2116d80a6771ad5475277cc85e87179e2.tar.gz
- added close() method to Transaction. closes out a transaction using rollback
if it's the outermost transaction, otherwise just ends without affecting the outer transaction. - transactional and non-transactional Session integrates better with bound connection; a close() will ensure that connection transactional state is the same as that which existed on it before being bound to the Session.
Diffstat (limited to 'lib/sqlalchemy/engine')
-rw-r--r--lib/sqlalchemy/engine/base.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 8fe34bf3f..faeb00cc9 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -864,6 +864,20 @@ class Transaction(object):
connection = property(lambda s:s._connection, doc="The Connection object referenced by this Transaction")
is_active = property(lambda s:s._is_active)
+ def close(self):
+ """close this transaction.
+
+ If this transaction is the base transaction in a begin/commit nesting,
+ the transaction will rollback(). Otherwise, the method returns.
+
+ This is used to cancel a Transaction without affecting the scope of
+ an enclosign transaction.
+ """
+ if not self._parent._is_active:
+ return
+ if self._parent is self:
+ self.rollback()
+
def rollback(self):
if not self._parent._is_active:
return