comparison roundup/backends/back_anydbm.py @ 4534:0dd6bdeb2eb5

issue2550729: Fix password history display for anydbm backend... ...thanks to Ralf Hemmecke for reporting.
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 28 Sep 2011 11:06:24 +0000
parents e572c5e28d0b
children fd972e18b21a
comparison
equal deleted inserted replaced
4533:792586cc78a4 4534:0dd6bdeb2eb5
573 logging.getLogger('roundup.hyperdb').debug( 573 logging.getLogger('roundup.hyperdb').debug(
574 'setjournal %s%s %r'%(classname, nodeid, journal)) 574 'setjournal %s%s %r'%(classname, nodeid, journal))
575 self.transactions.append((self.doSetJournal, (classname, nodeid, 575 self.transactions.append((self.doSetJournal, (classname, nodeid,
576 journal))) 576 journal)))
577 577
578 def fix_journal(self, classname, journal):
579 """ fix password entries to correct type """
580 pwprops = {}
581 for pn, prop in self.getclass(classname).properties.iteritems():
582 if isinstance(prop, hyperdb.Password):
583 pwprops [pn] = 1
584 if not pwprops:
585 return journal
586 for j in journal:
587 if j[3] == 'set':
588 for k, v in j[4].items():
589 if k in pwprops:
590 j[4][k] = password.JournalPassword(j[4][k])
591 return journal
592
578 def getjournal(self, classname, nodeid): 593 def getjournal(self, classname, nodeid):
579 """ get the journal for id 594 """ get the journal for id
580 595
581 Raise IndexError if the node doesn't exist (as per history()'s 596 Raise IndexError if the node doesn't exist (as per history()'s
582 API) 597 API)
609 elif error.args[0] != 2: 624 elif error.args[0] != 2:
610 # this isn't a "not found" error, be alarmed! 625 # this isn't a "not found" error, be alarmed!
611 raise 626 raise
612 if res: 627 if res:
613 # we have unsaved journal entries, return them 628 # we have unsaved journal entries, return them
614 return res 629 return self.fix_journal (classname, res)
615 raise IndexError('no such %s %s'%(classname, nodeid)) 630 raise IndexError('no such %s %s'%(classname, nodeid))
616 try: 631 try:
617 journal = marshal.loads(db[nodeid]) 632 journal = marshal.loads(db[nodeid])
618 except KeyError: 633 except KeyError:
619 db.close() 634 db.close()
620 if res: 635 if res:
621 # we have some unsaved journal entries, be happy! 636 # we have some unsaved journal entries, be happy!
622 return res 637 return self.fix_journal (classname, res)
623 raise IndexError('no such %s %s'%(classname, nodeid)) 638 raise IndexError('no such %s %s'%(classname, nodeid))
624 db.close() 639 db.close()
625 640
626 # add all the saved journal entries for this node 641 # add all the saved journal entries for this node
627 for nodeid, date_stamp, user, action, params in journal: 642 for nodeid, date_stamp, user, action, params in journal:
628 res.append((nodeid, date.Date(date_stamp), user, action, params)) 643 res.append((nodeid, date.Date(date_stamp), user, action, params))
629 return res 644 return self.fix_journal (classname, res)
630 645
631 def pack(self, pack_before): 646 def pack(self, pack_before):
632 """ Delete all journal entries except "create" before 'pack_before'. 647 """ Delete all journal entries except "create" before 'pack_before'.
633 """ 648 """
634 pack_before = pack_before.serialise() 649 pack_before = pack_before.serialise()

Roundup Issue Tracker: http://roundup-tracker.org/