Skip to content

Commit c36aa19

Browse files
author
Roche Compaan
committed
We need to keep the last 'set' entry in the journal...
...to preserve information on 'activity' for nodes.
1 parent c3d4f84 commit c36aa19

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

roundup/backends/back_anydbm.py

Lines changed: 13 additions & 1 deletion
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.24 2002-01-21 16:33:20 rochecompaan Exp $
18+
#$Id: back_anydbm.py,v 1.25 2002-01-22 05:06:08 rochecompaan 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
@@ -352,6 +352,15 @@ def pack(self, pack_before):
352352
params) = entry
353353
if date_stamp > pack_before or action == 'create':
354354
l.append(entry)
355+
elif action == 'set':
356+
# grab the last set entry to keep information on
357+
# activity
358+
last_set_entry = entry
359+
date_stamp = last_set_entry[1]
360+
# if the last set entry was made after the pack date
361+
# then it is already in the list
362+
if date_stamp < pack_before:
363+
l.append(last_set_entry)
355364
db[key] = marshal.dumps(l)
356365
if db_type == 'gdbm':
357366
db.reorganize()
@@ -444,6 +453,9 @@ def rollback(self):
444453

445454
#
446455
#$Log: not supported by cvs2svn $
456+
#Revision 1.24 2002/01/21 16:33:20 rochecompaan
457+
#You can now use the roundup-admin tool to pack the database
458+
#
447459
#Revision 1.23 2002/01/18 04:32:04 richard
448460
#Rollback was breaking because a message hadn't actually been written to the file. Needs
449461
#more investigation.

test/test_db.py

Lines changed: 8 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: test_db.py,v 1.16 2002-01-21 16:33:20 rochecompaan Exp $
18+
# $Id: test_db.py,v 1.17 2002-01-22 05:06:09 rochecompaan Exp $
1919

2020
import unittest, os, shutil
2121

@@ -241,13 +241,16 @@ def testJournals(self):
241241

242242
def testPack(self):
243243
self.db.issue.create(title="spam", status='1')
244+
self.db.commit()
244245
self.db.issue.set('1', status='2')
245246
self.db.commit()
247+
self.db.issue.set('1', status='3')
248+
self.db.commit()
246249

247250
pack_before = date.Date(". + 1d")
248251
self.db.pack(pack_before)
249252
journal = self.db.getjournal('issue', '1')
250-
self.assertEqual(1, len(journal))
253+
self.assertEqual(2, len(journal))
251254

252255
def testRetire(self):
253256
pass
@@ -344,6 +347,9 @@ def suite():
344347

345348
#
346349
# $Log: not supported by cvs2svn $
350+
# Revision 1.16 2002/01/21 16:33:20 rochecompaan
351+
# You can now use the roundup-admin tool to pack the database
352+
#
347353
# Revision 1.15 2002/01/19 13:16:04 rochecompaan
348354
# Journal entries for link and multilink properties can now be switched on
349355
# or off.

0 commit comments

Comments
 (0)