aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/metadata_api
diff options
context:
space:
mode:
authorJohn Nduli2024-09-24 09:46:59 +0300
committerBonfaceKilz2024-09-30 11:14:08 +0300
commit8e1e33aa8991477c3141116ab28aa28a324b0c41 (patch)
tree98cfcd9855065822ab0a8a40218ebbb76c49e70d /gn3/api/metadata_api
parentacf133de4cc482ba8c4954179757e301f52c751a (diff)
downloadgenenetwork3-8e1e33aa8991477c3141116ab28aa28a324b0c41.tar.gz
feat: rollback mysql transaction when rdf insert fails
Diffstat (limited to 'gn3/api/metadata_api')
-rw-r--r--gn3/api/metadata_api/wiki.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py
index 8dc4f9a..0fe228f 100644
--- a/gn3/api/metadata_api/wiki.py
+++ b/gn3/api/metadata_api/wiki.py
@@ -74,13 +74,17 @@ def edit_wiki(comment_id: int):
insert_dict["versionId"], cat_id)
)
- # Editing RDF:
- update_wiki_comment(
- insert_dict=insert_dict,
- sparql_user=current_app.config["SPARQL_USER"],
- sparql_password=current_app.config["SPARQL_PASSWORD"],
- sparql_auth_uri=current_app.config["SPARQL_AUTH_URI"]
- )
+ try:
+ # Editing RDF:
+ update_wiki_comment(
+ insert_dict=insert_dict,
+ sparql_user=current_app.config["SPARQL_USER"],
+ sparql_password=current_app.config["SPARQL_PASSWORD"],
+ sparql_auth_uri=current_app.config["SPARQL_AUTH_URI"]
+ )
+ except Exception as exc:
+ conn.rollback()
+ raise exc
return jsonify({"success": "ok"})
return jsonify(error="Error editing wiki entry, most likely due to DB error!"), 500