Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow transactions without context managers

  • Loading branch information...
commit 000f17e0cd39722aabceb2135c36bd9b1b8e341a 1 parent 55cc288
Jeff Jenkins authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 mongoalchemy/session.py
View
10 mongoalchemy/session.py
@@ -406,11 +406,17 @@ def clone(self, document):
del wrapped['_id']
return type(document).unwrap(wrapped, session=self)
- def __enter__(self):
+ def begin_trans(self):
self.transactions.append(uuid4())
return self
-
+
+ def __enter__(self):
+ return self.begin_trans()
+
def __exit__(self, exc_type, exc_val, exc_tb):
+ return self.end_trans(exc_type, exc_val, exc_tb)
+
+ def end_trans(self, exc_type=None, exc_val=None, exc_tb=None):
# Pop this level of transaction from the stack
id = self.transactions.pop()
Please sign in to comment.
Something went wrong with that request. Please try again.