def _commit_manually(*args, **kw): try: common.enter_transaction_management() common.managed(True) return func(*args, **kw) finally: common.leave_transaction_management()
def _autocommit(*args, **kw): try: common.enter_transaction_management(managed=False) common.managed(False) return func(*args, **kw) finally: common.leave_transaction_management()
def _commit_on_success(*args, **kw): try: common.enter_transaction_management() common.managed(True) try: res = func(*args, **kw) except: # All exceptions must be handled here (even string ones). common.rollback() raise else: try: common.commit() except: common.rollback() raise return res finally: common.leave_transaction_management()