05/16 Fix bugs 3

This commit is contained in:
Nguyen Ngo
2026-05-16 14:10:08 -04:00
parent edd81f4c59
commit 766fbfaa87
2 changed files with 17 additions and 8 deletions
+6 -1
View File
@@ -44,6 +44,11 @@ def log_action(action: str,
"""
Write a single AuditLog row. Safe to call from any request context.
⚠️ This function calls db.session.commit() internally.
Always call it AFTER the primary db.session.commit() for the business
transaction — never before. Calling it mid-transaction will commit any
dirty ORM state accumulated in the session up to that point.
Parameters
----------
action : One of the ACTION_* constants (or a custom string ≤ 50 chars).
@@ -90,4 +95,4 @@ def log_action(action: str,
try:
db.session.rollback()
except Exception:
pass
pass