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 autocommit(fn): | |
def wrapper(*args, **kwargs): | |
self = args[0] | |
cmd = fn(*args, **kwargs) | |
if isinstance(self, Transaction): | |
self.commands.append(cmd) | |
return cmd | |
else: | |
return cmd.execute() | |
return wrapper |