Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move commit and rollback to the mediator.

  • Loading branch information...
commit e538f4faab6a07d00253704c70c0857d79260b79 1 parent 5586d8a
Keith Gaughan authored

Showing 1 changed file with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +11 3 dbkit.py
14 dbkit.py
@@ -130,7 +130,7 @@ def transaction(self):
130 130 # The idea here is to fake the nesting of transactions. Only when
131 131 # we've gotten back to the topmost transaction context do we actually
132 132 # commit or rollback.
133   - with self._mdr as conn:
  133 + with self._mdr:
134 134 try:
135 135 self._depth += 1
136 136 yield self
@@ -143,10 +143,10 @@ def transaction(self):
143 143 except:
144 144 self._depth -= 1
145 145 if self._depth == 0:
146   - conn.rollback()
  146 + self._mdr.rollback()
147 147 raise
148 148 if self._depth == 0:
149   - conn.commit()
  149 + self._mdr.commit()
150 150
151 151 @contextlib.contextmanager
152 152 def cursor(self):
@@ -220,6 +220,14 @@ def close(self):
220 220 """Called to signal that any resources can be released."""
221 221 raise NotImplementedError()
222 222
  223 + def rollback(self):
  224 + """Rollback the current transaction."""
  225 + self.conn.rollback()
  226 +
  227 + def commit(self):
  228 + """Commit the current transaction."""
  229 + self.conn.commit()
  230 +
223 231
224 232 class SingleConnectionMediator(ConnectionMediatorBase):
225 233 """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.