diff roundup/backends/sessions_rdbms.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 0b154486ed38
children abee2c2c822e
line wrap: on
line diff
--- a/roundup/backends/sessions_rdbms.py	Thu Apr 19 20:01:43 2018 +0200
+++ b/roundup/backends/sessions_rdbms.py	Fri Apr 20 18:46:28 2018 +0200
@@ -5,7 +5,7 @@
 class. It's now also used for One Time Key handling too.
 """
 __docformat__ = 'restructuredtext'
-import os, time
+import os, time, logging
 from cgi import escape
 
 class BasicDatabase:
@@ -16,7 +16,7 @@
     name = None
     def __init__(self, db):
         self.db = db
-        self.cursor = self.db.cursor
+        self.conn, self.cursor = self.db.sql_open_connection()
 
     def clear(self):
         self.cursor.execute('delete from %ss'%self.name)
@@ -113,6 +113,15 @@
         self.cursor.execute('delete from %ss where %s_time < %s'%(self.name,
             self.name, self.db.arg), (old, ))
 
+    def commit(self):
+        logger = logging.getLogger('roundup.hyperdb.backend')
+        logger.info('commit %s' % self.name)
+        self.conn.commit()
+        self.cursor = self.conn.cursor()
+
+    def close(self):
+        self.conn.close()
+
 class Sessions(BasicDatabase):
     name = 'session'
 

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