diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-28 23:57:14 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-28 23:57:14 +0000 |
| commit | 4b8897902105379a97363a0f3d58f1e87e65b42b (patch) | |
| tree | 59ab875f00ea49f2768310347b1c197b2d723849 /lib/sqlalchemy/engine | |
| parent | 123cb1064ce6ecd841d32df08f7969acbc154cd9 (diff) | |
| download | sqlalchemy-4b8897902105379a97363a0f3d58f1e87e65b42b.tar.gz | |
pool needed weakref
modified auto rollback to only occur when no transaction
more unit tests
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/threadlocal.py | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index f3573711b..eaaae29d2 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -167,7 +167,7 @@ class Connectable(object): def _not_impl(self): raise NotImplementedError() engine = property(_not_impl, doc="returns the Engine which this Connectable is associated with.") - + class Connection(Connectable): """represents a single DBAPI connection returned from the underlying connection pool. Provides execution support for string-based SQL statements as well as ClauseElement, Compiled and DefaultGenerator objects. @@ -214,6 +214,9 @@ class Connection(Connectable): # extra step if not self.in_transaction() and re.match(r'UPDATE|INSERT|CREATE|DELETE|DROP', statement.lstrip().upper()): self._commit_impl() + def _autorollback(self): + if not self.in_transaction(): + self._rollback_impl() def close(self): if self.__connection is not None: self.__connection.close() @@ -315,7 +318,8 @@ class Connection(Connectable): try: self.__engine.dialect.do_execute(c, statement, parameters, context=context) except Exception, e: - self._rollback_impl() + self._autorollback() + #self._rollback_impl() if self.__close_with_result: self.close() raise exceptions.SQLError(statement, parameters, e) diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index 000a854b2..a96af4ea8 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -67,10 +67,8 @@ class TLConnection(base.Connection): class TLTransaction(base.Transaction): def commit(self): - print "TL COMMIT" base.Transaction.commit(self) if not self.is_active: - print "RESET" self.connection.session.reset() def rollback(self): base.Transaction.rollback(self) |
