diff roundup/backends/back_sqlite.py @ 5319:62de601bdf6f

Fix commits although a Reject exception is raised Fix the problem that changes are committed to the database (due to commits to otk handling) even when a Reject exception occurs. The fix implements separate database connections for otk/session handling and normal database operation.
author Ralf Schlatterbeck <rsc@runtux.com>
date Fri, 20 Apr 2018 18:46:28 +0200
parents 506c7ee9a385
children 56c9bcdea47f
line wrap: on
line diff
--- a/roundup/backends/back_sqlite.py	Thu Apr 19 20:01:43 2018 +0200
+++ b/roundup/backends/back_sqlite.py	Fri Apr 20 18:46:28 2018 +0200
@@ -12,6 +12,8 @@
 
 from roundup import hyperdb, date, password
 from roundup.backends import rdbms_common
+from roundup.backends.sessions_dbm import Sessions, OneTimeKeys
+
 sqlite_version = None
 try:
     import sqlite3 as sqlite
@@ -94,6 +96,19 @@
         hyperdb.Multilink : lambda x: x,    # used in journal marshalling
     }
 
+    # We're using DBM for managing session info and one-time keys:
+    # For SQL database storage of this info we would need two concurrent
+    # connections to the same database which SQLite doesn't support
+    def getSessionManager(self):
+        if not self.Session:
+            self.Session = Sessions(self)
+        return self.Session
+
+    def getOTKManager(self):
+        if not self.Otk:
+            self.Otk = OneTimeKeys(self)
+        return self.Otk
+
     def sqlite_busy_handler(self, data, table, count):
         """invoked whenever SQLite tries to access a database that is locked"""
         now = time.time()
@@ -349,7 +364,7 @@
     def __repr__(self):
         return '<roundlite 0x%x>'%id(self)
 
-    def sql_commit(self, fail_ok=False):
+    def sql_commit(self):
         """ Actually commit to the database.
 
             Ignore errors if there's nothing to commit.

Roundup Issue Tracker: http://roundup-tracker.org/