diff roundup/backends/back_bsddb.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 c7119e74fcf8
children 8a908bbad1ef
line wrap: on
line diff
--- a/roundup/backends/back_bsddb.py	Wed Mar 26 11:02:28 2003 +0000
+++ b/roundup/backends/back_bsddb.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_bsddb.py,v 1.24 2002-09-13 08:20:11 richard Exp $
+#$Id: back_bsddb.py,v 1.25 2003-03-26 11:19:28 richard Exp $
 '''
 This module defines a backend that saves the hyperdatabase in BSDDB.
 '''
@@ -75,6 +75,27 @@
     def getjournal(self, classname, nodeid):
         ''' get the journal for id
         '''
+        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:
@@ -85,14 +106,18 @@
             raise IndexError, 'no such %s %s'%(classname, nodeid)
         # more handling of bad journals
         if not db.has_key(nodeid):
+            if res:
+                # we have some unsaved journal entries, be happy!
+                return res
             raise IndexError, 'no such %s %s'%(classname, nodeid)
         journal = marshal.loads(db[nodeid])
-        res = []
+        db.close()
+
+        # add all the saved journal entries for this node
         for entry in journal:
             (nodeid, date_stamp, user, action, params) = entry
             date_obj = date.Date(date_stamp)
             res.append((nodeid, date_obj, user, action, params))
-        db.close()
         return res
 
     def getCachedJournalDB(self, classname):

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