Skip to content

Commit 6e62a33

Browse files
author
Richard Jones
committed
fixed missing (pre-commit) journal entries in *dbm backends [SF#679217]
1 parent 1ca0450 commit 6e62a33

File tree

4 files changed

+101
-47
lines changed

4 files changed

+101
-47
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Fixed:
7777
- added example HTML tempating for vacation flag (sf bug 701722)
7878
- finally, tables autosize columns (sf bug 609070)
7979
- added creation to index columns (sf bug 708247)
80+
- fixed missing (pre-commit) journal entries in *dbm backends (sf bug 679217)
8081

8182

8283
2003-??-?? 0.5.7

roundup/backends/back_anydbm.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.117 2003-03-26 10:43:59 richard Exp $
18+
#$Id: back_anydbm.py,v 1.118 2003-03-26 11:19:28 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -481,6 +481,25 @@ def getjournal(self, classname, nodeid):
481481
'''
482482
if __debug__:
483483
print >>hyperdb.DEBUG, 'getjournal', (self, classname, nodeid)
484+
485+
# our journal result
486+
res = []
487+
488+
# add any journal entries for transactions not committed to the
489+
# database
490+
for method, args in self.transactions:
491+
if method != self.doSaveJournal:
492+
continue
493+
(cache_classname, cache_nodeid, cache_action, cache_params,
494+
cache_creator, cache_creation) = args
495+
if cache_classname == classname and cache_nodeid == nodeid:
496+
if not cache_creator:
497+
cache_creator = self.curuserid
498+
if not cache_creation:
499+
cache_creation = date.Date()
500+
res.append((cache_nodeid, cache_creation, cache_creator,
501+
cache_action, cache_params))
502+
484503
# attempt to open the journal - in some rare cases, the journal may
485504
# not exist
486505
try:
@@ -495,9 +514,13 @@ def getjournal(self, classname, nodeid):
495514
journal = marshal.loads(db[nodeid])
496515
except KeyError:
497516
db.close()
517+
if res:
518+
# we have some unsaved journal entries, be happy!
519+
return res
498520
raise IndexError, 'no such %s %s'%(classname, nodeid)
499521
db.close()
500-
res = []
522+
523+
# add all the saved journal entries for this node
501524
for nodeid, date_stamp, user, action, params in journal:
502525
res.append((nodeid, date.Date(date_stamp), user, action, params))
503526
return res

roundup/backends/back_bsddb.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_bsddb.py,v 1.24 2002-09-13 08:20:11 richard Exp $
18+
#$Id: back_bsddb.py,v 1.25 2003-03-26 11:19:28 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in BSDDB.
2121
'''
@@ -75,6 +75,27 @@ def opendb(self, name, mode):
7575
def getjournal(self, classname, nodeid):
7676
''' get the journal for id
7777
'''
78+
if __debug__:
79+
print >>hyperdb.DEBUG, 'getjournal', (self, classname, nodeid)
80+
81+
# our journal result
82+
res = []
83+
84+
# add any journal entries for transactions not committed to the
85+
# database
86+
for method, args in self.transactions:
87+
if method != self.doSaveJournal:
88+
continue
89+
(cache_classname, cache_nodeid, cache_action, cache_params,
90+
cache_creator, cache_creation) = args
91+
if cache_classname == classname and cache_nodeid == nodeid:
92+
if not cache_creator:
93+
cache_creator = self.curuserid
94+
if not cache_creation:
95+
cache_creation = date.Date()
96+
res.append((cache_nodeid, cache_creation, cache_creator,
97+
cache_action, cache_params))
98+
7899
# attempt to open the journal - in some rare cases, the journal may
79100
# not exist
80101
try:
@@ -85,14 +106,18 @@ def getjournal(self, classname, nodeid):
85106
raise IndexError, 'no such %s %s'%(classname, nodeid)
86107
# more handling of bad journals
87108
if not db.has_key(nodeid):
109+
if res:
110+
# we have some unsaved journal entries, be happy!
111+
return res
88112
raise IndexError, 'no such %s %s'%(classname, nodeid)
89113
journal = marshal.loads(db[nodeid])
90-
res = []
114+
db.close()
115+
116+
# add all the saved journal entries for this node
91117
for entry in journal:
92118
(nodeid, date_stamp, user, action, params) = entry
93119
date_obj = date.Date(date_stamp)
94120
res.append((nodeid, date_obj, user, action, params))
95-
db.close()
96121
return res
97122

98123
def getCachedJournalDB(self, classname):

0 commit comments

Comments
 (0)