Skip to content

Commit c4b47af

Browse files
author
Richard Jones
committed
fixed anydbm & metakit import/export ([SF#965216], [SF#964457], [SF#964450])
1 parent db012ee commit c4b47af

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Fixed:
1616
- re-acquire the OTK manager when we re-open the database
1717
- mailgw handler can close the database on us
1818
- fixed grouping by a NULL Link value
19+
- fixed anydbm import/export (sf bugs 965216, 964457, 964450)
1920

2021

2122
2004-05-28 0.7.3

roundup/backends/back_anydbm.py

Lines changed: 4 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_anydbm.py,v 1.149 2004-05-23 23:24:47 richard Exp $
18+
#$Id: back_anydbm.py,v 1.150 2004-06-08 05:30:32 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -2009,6 +2009,7 @@ def export_journals(self):
20092009
r = []
20102010
for nodeid in self.getnodeids():
20112011
for nodeid, date, user, action, params in self.history(nodeid):
2012+
print (nodeid, date, user, action, params)
20122013
date = date.get_tuple()
20132014
if action == 'set':
20142015
for propname, value in params.items():
@@ -2035,7 +2036,7 @@ def import_journals(self, entries):
20352036
d = {}
20362037
for l in entries:
20372038
l = map(eval, l)
2038-
nodeid, date, user, action, params = l
2039+
nodeid, jdate, user, action, params = l
20392040
r = d.setdefault(nodeid, [])
20402041
if action == 'set':
20412042
for propname, value in params.items():
@@ -2051,7 +2052,7 @@ def import_journals(self, entries):
20512052
pwd.unpack(value)
20522053
value = pwd
20532054
params[propname] = value
2054-
r.append((nodeid, date.Date(date), user, action, params))
2055+
r.append((nodeid, date.Date(jdate), user, action, params))
20552056

20562057
for nodeid, l in d.items():
20572058
self.db.setjournal(self.classname, nodeid, l)

roundup/backends/back_metakit.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.72 2004-05-23 23:24:47 richard Exp $
1+
# $Id: back_metakit.py,v 1.73 2004-06-08 05:30:32 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -209,8 +209,8 @@ def addjournal(self, tablenm, nodeid, action, params, creator=None,
209209
nodeid=int(nodeid),
210210
date=creation,
211211
action=action,
212-
user = creator,
213-
params = marshal.dumps(params))
212+
user=creator,
213+
params=marshal.dumps(params))
214214

215215
def setjournal(self, tablenm, nodeid, journal):
216216
'''Set the journal to the "journal" list.'''
@@ -223,7 +223,7 @@ def setjournal(self, tablenm, nodeid, journal):
223223
nodeid=int(nodeid),
224224
date=date,
225225
action=action,
226-
user=user,
226+
user=int(user),
227227
params=marshal.dumps(params))
228228

229229
def getjournal(self, tablenm, nodeid):
@@ -361,6 +361,15 @@ def numfiles(self):
361361
_UNLINK : 'unlink',
362362
}
363363

364+
_names_to_actionnames = {
365+
'create': _CREATE,
366+
'set': _SET,
367+
'retire': _RETIRE,
368+
'restore': _RESTORE,
369+
'link': _LINK,
370+
'unlink': _UNLINK,
371+
}
372+
364373
_marker = []
365374

366375
_ALLOWSETTINGPRIVATEPROPS = 0
@@ -1700,7 +1709,8 @@ def import_journals(self, entries):
17001709
d = {}
17011710
for l in entries:
17021711
l = map(eval, l)
1703-
nodeid, date, user, action, params = l
1712+
nodeid, jdate, user, action, params = l
1713+
jdate = int(calendar.timegm(date.Date(jdate).get_tuple()))
17041714
r = d.setdefault(nodeid, [])
17051715
if action == 'set':
17061716
for propname, value in params.items():
@@ -1716,7 +1726,8 @@ def import_journals(self, entries):
17161726
pwd.unpack(value)
17171727
value = pwd
17181728
params[propname] = value
1719-
r.append((nodeid, date.Date(date), user, action, params))
1729+
action = _names_to_actionnames[action]
1730+
r.append((nodeid, jdate, user, action, params))
17201731

17211732
for nodeid, l in d.items():
17221733
self.db.setjournal(self.classname, nodeid, l)

0 commit comments

Comments
 (0)