Add decorator for session management.

This commit is contained in:
Alexis Lahouze 2015-06-11 23:27:55 +02:00
parent 4f29c4c455
commit af506a3091

View File

@ -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