From e153ca9aa78e244ea113cb3fbc02d29094ed0dcd Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Wed, 28 Sep 2011 11:06:24 +0000 Subject: [PATCH] issue2550729: Fix password history display for anydbm backend, thanks to Ralf Hemmecke for reporting. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4647 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 2 ++ roundup/backends/back_anydbm.py | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 77136e6..5eddc13 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -24,6 +24,8 @@ Fixed: field of a user -- this would match substrings, e.g. if the user has discuss-support@example.com as an alternate email and an incoming mail is addressed to support@example.com this would (wrongly) match. (Ralf) +- issue2550729: Fix password history display for anydbm backend, thanks + to Ralf Hemmecke for reporting. 2011-07-15 1.4.19 (r4638) diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 77f1609..233de40 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -575,6 +575,21 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): self.transactions.append((self.doSetJournal, (classname, nodeid, journal))) + def fix_journal(self, classname, journal): + """ fix password entries to correct type """ + pwprops = {} + for pn, prop in self.getclass(classname).properties.iteritems(): + if isinstance(prop, hyperdb.Password): + pwprops [pn] = 1 + if not pwprops: + return journal + for j in journal: + if j[3] == 'set': + for k, v in j[4].items(): + if k in pwprops: + j[4][k] = password.JournalPassword(j[4][k]) + return journal + def getjournal(self, classname, nodeid): """ get the journal for id @@ -611,7 +626,7 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): raise if res: # we have unsaved journal entries, return them - return res + return self.fix_journal (classname, res) raise IndexError('no such %s %s'%(classname, nodeid)) try: journal = marshal.loads(db[nodeid]) @@ -619,14 +634,14 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): db.close() if res: # we have some unsaved journal entries, be happy! - return res + return self.fix_journal (classname, res) raise IndexError('no such %s %s'%(classname, nodeid)) db.close() # 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 + return self.fix_journal (classname, res) def pack(self, pack_before): """ Delete all journal entries except "create" before 'pack_before'. -- 2.30.2