Code

issue2550729: Fix password history display for anydbm backend, thanks to
authorschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Wed, 28 Sep 2011 11:06:24 +0000 (11:06 +0000)
committerschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Wed, 28 Sep 2011 11:06:24 +0000 (11:06 +0000)
Ralf Hemmecke for reporting.

git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4647 57a73879-2fb5-44c3-a270-3262357dd7e2

CHANGES.txt
roundup/backends/back_anydbm.py

index 77136e6e974e78faa4e95fd775f8abf7dc398fd7..5eddc13c2cdf5adf08d4e0b30cdae037c2b52f04 100644 (file)
@@ -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)
 
index 77f16096dad48aa323ef4b496cc7052f7ffc20c2..233de403cb6d1117e89834ea82e8daa3db14b3aa 100644 (file)
@@ -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'.