diff --git a/accountant/__init__.py b/accountant/__init__.py index 8224fc0..c2d1872 100644 --- a/accountant/__init__.py +++ b/accountant/__init__.py @@ -46,6 +46,16 @@ def session_scope(): finally: session.close() + +def session_aware(f): + def wrapper(*args, **kwargs): + with session_scope() as session: + kwargs['session'] = session + + return f(*args, **kwargs) + return wrapper + + # Must be after db declaration because the blueprints may need it. from .api import api from .frontend import frontend