Created
May 24, 2011 17:54
-
-
Save k4ml/989248 to your computer and use it in GitHub Desktop.
Catch transaction before it being caught by transaction.commit_manually
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transact(func): | |
""" | |
Usage: | |
@transaction.commit_manually | |
@transact | |
def some_function(a, b): | |
do_something() | |
""" | |
def decorated(*args, **kwargs): | |
try: | |
func(*args, **kwargs) | |
except Exception, e: | |
print e | |
transaction.rollback() | |
sys.exit() | |
return decorated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment