Skip to content

Instantly share code, notes, and snippets.



Last active Aug 22, 2019
What would you like to do?
def dbconnection(function):
"""Decorator for getting at the database connection.
Use this to avoid having to access the global ``
attribute. This calls the function with `store` as the first argument.
def wrapper(*args, **kws):
# args[0] is self, if there is one.
if len(args) > 0:
return function(args[0],, *args[1:], **kws)
return function(, **kws)
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment