Mercurial > p > roundup > code
diff roundup/backends/back_anydbm.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 | 35ea9b1efc14 |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Thu Apr 19 20:01:43 2018 +0200 +++ b/roundup/backends/back_anydbm.py Fri Apr 20 18:46:28 2018 +0200 @@ -191,6 +191,9 @@ self.lockfile.write(str(os.getpid())) self.lockfile.flush() + self.Session = None + self.Otk = None + def post_init(self): """Called once the schema initialisation has finished. """ @@ -204,10 +207,14 @@ self.reindex() def getSessionManager(self): - return Sessions(self) + if not self.Session: + self.Session = Sessions(self) + return self.Session def getOTKManager(self): - return OneTimeKeys(self) + if not self.Otk: + self.Otk = OneTimeKeys(self) + return self.Otk def reindex(self, classname=None, show_progress=False): if classname: @@ -698,17 +705,11 @@ # # Basic transaction support # - def commit(self, fail_ok=False): + def commit(self): """ Commit the current transactions. Save all data changed since the database was opened or since the last commit() or rollback(). - - fail_ok indicates that the commit is allowed to fail. This is used - in the web interface when committing cleaning of the session - database. We don't care if there's a concurrency issue there. - - The only backend this seems to affect is postgres. """ logging.getLogger('roundup.hyperdb.backend').info('commit %s transactions'%( len(self.transactions)))
