diff options
| author | Ants Aasma <ants.aasma@gmail.com> | 2008-09-30 12:04:23 +0000 |
|---|---|---|
| committer | Ants Aasma <ants.aasma@gmail.com> | 2008-09-30 12:04:23 +0000 |
| commit | 3eefe60bcf732352bbaef7baa4efabe8bdc46439 (patch) | |
| tree | 32e8ef626e9de4374c3aa02d7607881440eee5a1 /lib | |
| parent | 4c53406cab9bef94331bd060a8f3ab3f5faee754 (diff) | |
| download | sqlalchemy-3eefe60bcf732352bbaef7baa4efabe8bdc46439.tar.gz | |
Issue a better error message when someone decides to meddle with the active transaction from within a context manager.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index cbff0ef0d..d4d512034 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -244,9 +244,9 @@ class SessionTransaction(object): "The transaction is inactive due to a rollback in a " "subtransaction. Issue rollback() to cancel the transaction.") - def _assert_is_open(self): + def _assert_is_open(self, error_msg="The transaction is closed"): if self.session is None: - raise sa_exc.InvalidRequestError("The transaction is closed") + raise sa_exc.InvalidRequestError(error_msg) @property def _is_transaction_boundary(self): @@ -438,6 +438,7 @@ class SessionTransaction(object): return self def __exit__(self, type, value, traceback): + self._assert_is_open("Cannot end transaction context. The transaction was closed from within the context") if self.session.transaction is None: return if type is None: |
