aboutsummaryrefslogtreecommitdiff
path: root/src/web/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/controllers')
-rw-r--r--src/web/controllers/abstract.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/web/controllers/abstract.py b/src/web/controllers/abstract.py
index 5cebd39e..7e167722 100644
--- a/src/web/controllers/abstract.py
+++ b/src/web/controllers/abstract.py
@@ -94,6 +94,7 @@ class AbstractController:
try:
db.session.commit()
except Exception as e:
+ db.session.rollback()
logger.exception(str(e))
return obj
@@ -103,13 +104,19 @@ class AbstractController:
def update(self, filters, attrs):
assert attrs, "attributes to update must not be empty"
result = self._get(**filters).update(attrs, synchronize_session=False)
- db.session.commit()
+ try:
+ db.session.commit()
+ except Exception as e:
+ db.session.rollback()
return result
def delete(self, obj_id):
obj = self.get(id=obj_id)
db.session.delete(obj)
- db.session.commit()
+ try:
+ db.session.commit()
+ except Exception as e:
+ db.session.rollback()
return obj
def _has_right_on(self, obj):
bgstack15