Index: db/transaction.py
===================================================================
--- db/transaction.py	(revision 9832)
+++ db/transaction.py	(working copy)
@@ -265,3 +265,27 @@
             leave_transaction_management()
 
     return wraps(func)(_commit_manually)
+
+####################
+# CONTEXT MANAGERS #
+####################
+class Transaction(object):
+    @classmethod
+    def __enter__(cls):
+        enter_transaction_management()
+        managed(True)
+    
+    @classmethod
+    def __exit__(cls, exc_type, value, traceback):
+        try:
+            if exc_type is None:
+                # Nested block executed successfully
+                if is_dirty():
+                    commit()
+            else:
+                # Some exception was raised
+                if is_dirty():
+                    rollback()
+                return False # re-raises the exception
+        finally:
+            leave_transaction_management()
