Last active
August 22, 2019 10:36
-
-
Save berserker1/6b214626042a6c976f780b33d2d12f32 to your computer and use it in GitHub Desktop.
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 dbconnection(function): | |
"""Decorator for getting at the database connection. | |
Use this to avoid having to access the global `config.db.store` | |
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], config.db.store, *args[1:], **kws) | |
else: | |
return function(config.db.store, **kws) | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment