--- a/server/serverctl.py Thu Mar 28 19:24:46 2013 +0100
+++ b/server/serverctl.py Fri Dec 19 12:08:01 2014 +0100
@@ -207,6 +207,22 @@
@contextmanager
+def db_transaction(source, privilege):
+ """Open a transaction to the instance database"""
+ cnx = system_source_cnx(source, special_privs=privilege)
+ cursor = cnx.cursor()
+ try:
+ yield cursor
+ except:
+ cnx.rollback()
+ cnx.close()
+ raise
+ else:
+ cnx.commit()
+ cnx.close()
+
+
+@contextmanager
def db_sys_transaction(source, privilege):
"""Open a transaction to the system database"""
cnx = _db_sys_cnx(source, privilege)