comparison 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
comparison
equal deleted inserted replaced
5318:506c7ee9a385 5319:62de601bdf6f
10 10
11 import os, base64, marshal, shutil, time, logging 11 import os, base64, marshal, shutil, time, logging
12 12
13 from roundup import hyperdb, date, password 13 from roundup import hyperdb, date, password
14 from roundup.backends import rdbms_common 14 from roundup.backends import rdbms_common
15 from roundup.backends.sessions_dbm import Sessions, OneTimeKeys
16
15 sqlite_version = None 17 sqlite_version = None
16 try: 18 try:
17 import sqlite3 as sqlite 19 import sqlite3 as sqlite
18 sqlite_version = 3 20 sqlite_version = 3
19 except ImportError: 21 except ImportError:
91 hyperdb.Boolean : int, 93 hyperdb.Boolean : int,
92 hyperdb.Integer : int, 94 hyperdb.Integer : int,
93 hyperdb.Number : rdbms_common._num_cvt, 95 hyperdb.Number : rdbms_common._num_cvt,
94 hyperdb.Multilink : lambda x: x, # used in journal marshalling 96 hyperdb.Multilink : lambda x: x, # used in journal marshalling
95 } 97 }
98
99 # We're using DBM for managing session info and one-time keys:
100 # For SQL database storage of this info we would need two concurrent
101 # connections to the same database which SQLite doesn't support
102 def getSessionManager(self):
103 if not self.Session:
104 self.Session = Sessions(self)
105 return self.Session
106
107 def getOTKManager(self):
108 if not self.Otk:
109 self.Otk = OneTimeKeys(self)
110 return self.Otk
96 111
97 def sqlite_busy_handler(self, data, table, count): 112 def sqlite_busy_handler(self, data, table, count):
98 """invoked whenever SQLite tries to access a database that is locked""" 113 """invoked whenever SQLite tries to access a database that is locked"""
99 now = time.time() 114 now = time.time()
100 if count == 1: 115 if count == 1:
347 raise 362 raise
348 363
349 def __repr__(self): 364 def __repr__(self):
350 return '<roundlite 0x%x>'%id(self) 365 return '<roundlite 0x%x>'%id(self)
351 366
352 def sql_commit(self, fail_ok=False): 367 def sql_commit(self):
353 """ Actually commit to the database. 368 """ Actually commit to the database.
354 369
355 Ignore errors if there's nothing to commit. 370 Ignore errors if there's nothing to commit.
356 """ 371 """
357 try: 372 try:

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