Clean up LoggingTransaction

pull/12/head
Erik Johnston 2014-10-28 10:53:11 +00:00
parent 8e358ef35a
commit 967ce43b59
1 changed files with 4 additions and 10 deletions

View File

@ -39,14 +39,11 @@ class LoggingTransaction(object):
def __init__(self, txn): def __init__(self, txn):
object.__setattr__(self, "txn", txn) object.__setattr__(self, "txn", txn)
def __getattribute__(self, name): def __getattr__(self, name):
if name == "execute": return getattr(self.txn, name)
return object.__getattribute__(self, "execute")
return getattr(object.__getattribute__(self, "txn"), name)
def __setattr__(self, name, value): def __setattr__(self, name, value):
setattr(object.__getattribute__(self, "txn"), name, value) setattr(self.txn, name, value)
def execute(self, sql, *args, **kwargs): def execute(self, sql, *args, **kwargs):
# TODO(paul): Maybe use 'info' and 'debug' for values? # TODO(paul): Maybe use 'info' and 'debug' for values?
@ -60,12 +57,9 @@ class LoggingTransaction(object):
# Don't let logging failures stop SQL from working # Don't let logging failures stop SQL from working
pass pass
# TODO(paul): Here would be an excellent place to put some timing
# measurements, and log (warning?) slow queries.
start = time.clock() * 1000 start = time.clock() * 1000
try: try:
return object.__getattribute__(self, "txn").execute( return self.txn.execute(
sql, *args, **kwargs sql, *args, **kwargs
) )
finally: finally: