server/rest: rollback session on query exception

Kills complaints from sqlalchemy when an error happens during
insertion/update hook.
This commit is contained in:
rr- 2017-02-02 19:40:21 +01:00
parent 07d0b43d4c
commit af6c35ed6b
1 changed files with 3 additions and 0 deletions

View File

@ -93,6 +93,9 @@ def application(env, start_response):
hook(ctx) hook(ctx)
try: try:
response = handler(ctx, match.groupdict()) response = handler(ctx, match.groupdict())
except:
ctx.session.rollback()
raise
finally: finally:
for hook in middleware.post_hooks: for hook in middleware.post_hooks:
hook(ctx) hook(ctx)