Add decorator for session management.
This commit is contained in:
parent
4f29c4c455
commit
af506a3091
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user