Mercurial > p > roundup > code
diff roundup/backends/back_anydbm.py @ 1567:fc8998ce6274
fixed missing (pre-commit) journal entries in *dbm backends [SF#679217]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 26 Mar 2003 11:19:28 +0000 |
| parents | e2a8ce4d2317 |
| children | 33a0d94c7658 |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Wed Mar 26 11:02:28 2003 +0000 +++ b/roundup/backends/back_anydbm.py Wed Mar 26 11:19:28 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.117 2003-03-26 10:43:59 richard Exp $ +#$Id: back_anydbm.py,v 1.118 2003-03-26 11:19:28 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -481,6 +481,25 @@ ''' if __debug__: print >>hyperdb.DEBUG, 'getjournal', (self, classname, nodeid) + + # our journal result + res = [] + + # add any journal entries for transactions not committed to the + # database + for method, args in self.transactions: + if method != self.doSaveJournal: + continue + (cache_classname, cache_nodeid, cache_action, cache_params, + cache_creator, cache_creation) = args + if cache_classname == classname and cache_nodeid == nodeid: + if not cache_creator: + cache_creator = self.curuserid + if not cache_creation: + cache_creation = date.Date() + res.append((cache_nodeid, cache_creation, cache_creator, + cache_action, cache_params)) + # attempt to open the journal - in some rare cases, the journal may # not exist try: @@ -495,9 +514,13 @@ journal = marshal.loads(db[nodeid]) except KeyError: db.close() + if res: + # we have some unsaved journal entries, be happy! + return res raise IndexError, 'no such %s %s'%(classname, nodeid) db.close() - res = [] + + # add all the saved journal entries for this node for nodeid, date_stamp, user, action, params in journal: res.append((nodeid, date.Date(date_stamp), user, action, params)) return res
