Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move commit and rollback to the mediator.

  • Loading branch information...
commit e538f4faab6a07d00253704c70c0857d79260b79 1 parent 5586d8a
@kgaughan authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 dbkit.py
View
14 dbkit.py
@@ -130,7 +130,7 @@ def transaction(self):
# The idea here is to fake the nesting of transactions. Only when
# we've gotten back to the topmost transaction context do we actually
# commit or rollback.
- with self._mdr as conn:
+ with self._mdr:
try:
self._depth += 1
yield self
@@ -143,10 +143,10 @@ def transaction(self):
except:
self._depth -= 1
if self._depth == 0:
- conn.rollback()
+ self._mdr.rollback()
raise
if self._depth == 0:
- conn.commit()
+ self._mdr.commit()
@contextlib.contextmanager
def cursor(self):
@@ -220,6 +220,14 @@ def close(self):
"""Called to signal that any resources can be released."""
raise NotImplementedError()
+ def rollback(self):
+ """Rollback the current transaction."""
+ self.conn.rollback()
+
+ def commit(self):
+ """Commit the current transaction."""
+ self.conn.commit()
+
class SingleConnectionMediator(ConnectionMediatorBase):
"""Mediates access to a single unpooled connection."""

0 comments on commit e538f4f

Please sign in to comment.
Something went wrong with that request. Please try again.