From: rochecompaan Date: Sat, 19 Jan 2002 13:16:04 +0000 (+0000) Subject: Journal entries for link and multilink properties can now be switched on X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1057f0ce9f77c0eac42161add23e693fe1c13388;p=roundup.git Journal entries for link and multilink properties can now be switched on or off. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@567 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 723fe16..e88610f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,8 @@ are given with the most recent entry first. 2002-01-?? - 0.4.0?? Feature: . much nicer history display (actualy real handling of property types etc) + . journal entries for link and mutlilink properties can be switched on or + off Fixed: . handle attachments with no name (eg tnef) diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 6551535..15f5c80 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.49 2002-01-16 07:02:57 richard Exp $ +# $Id: hyperdb.py,v 1.50 2002-01-19 13:16:04 rochecompaan Exp $ __doc__ = """ Hyperdatabase implementation, especially field types. @@ -54,8 +54,9 @@ class Interval: class Link: """An object designating a Link property that links to a node in a specified class.""" - def __init__(self, classname): + def __init__(self, classname, do_journal='no'): self.classname = classname + self.do_journal = do_journal == 'yes' def __repr__(self): return '<%s to "%s">'%(self.__class__, self.classname) @@ -63,8 +64,9 @@ class Multilink: """An object designating a Multilink property that links to nodes in a specified class. """ - def __init__(self, classname): + def __init__(self, classname, do_journal='no'): self.classname = classname + self.do_journal = do_journal == 'yes' def __repr__(self): return '<%s to "%s">'%(self.__class__, self.classname) @@ -309,8 +311,9 @@ class Class: propvalues[key] = value # register the link with the newly linked node - self.db.addjournal(link_class, value, 'link', - (self.classname, newid, key)) + if self.properties[key].do_journal: + self.db.addjournal(link_class, value, 'link', + (self.classname, newid, key)) elif isinstance(prop, Multilink): if type(value) != type([]): @@ -336,8 +339,9 @@ class Class: if not self.db.hasnode(link_class, id): raise IndexError, '%s has no node %s'%(link_class, id) # register the link with the newly linked node - self.db.addjournal(link_class, id, 'link', - (self.classname, newid, key)) + if self.properties[key].do_journal: + self.db.addjournal(link_class, id, 'link', + (self.classname, newid, key)) elif isinstance(prop, String): if type(value) != type(''): @@ -505,15 +509,16 @@ class Class: if not self.db.hasnode(link_class, value): raise IndexError, '%s has no node %s'%(link_class, value) - # register the unlink with the old linked node - if node[key] is not None: - self.db.addjournal(link_class, node[key], 'unlink', - (self.classname, nodeid, key)) + if self.properties[key].do_journal: + # register the unlink with the old linked node + if node[key] is not None: + self.db.addjournal(link_class, node[key], 'unlink', + (self.classname, nodeid, key)) - # register the link with the newly linked node - if value is not None: - self.db.addjournal(link_class, value, 'link', - (self.classname, nodeid, key)) + # register the link with the newly linked node + if value is not None: + self.db.addjournal(link_class, value, 'link', + (self.classname, nodeid, key)) elif isinstance(prop, Multilink): if type(value) != type([]): @@ -543,19 +548,22 @@ class Class: if id in value: continue # register the unlink with the old linked node - self.db.addjournal(link_class, id, 'unlink', - (self.classname, nodeid, key)) + if self.properties[key].do_journal: + self.db.addjournal(link_class, id, 'unlink', + (self.classname, nodeid, key)) l.remove(id) # handle additions for id in value: if not self.db.hasnode(link_class, id): - raise IndexError, '%s has no node %s'%(link_class, id) + raise IndexError, '%s has no node %s'%( + link_class, id) if id in l: continue # register the link with the newly linked node - self.db.addjournal(link_class, id, 'link', - (self.classname, nodeid, key)) + if self.properties[key].do_journal: + self.db.addjournal(link_class, id, 'link', + (self.classname, nodeid, key)) l.append(id) elif isinstance(prop, String): @@ -1047,6 +1055,10 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.49 2002/01/16 07:02:57 richard +# . lots of date/interval related changes: +# - more relaxed date format for input +# # Revision 1.48 2002/01/14 06:32:34 richard # . #502951 ] adding new properties to old database # diff --git a/test/test_db.py b/test/test_db.py index 8e51e01..9632d36 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_db.py,v 1.14 2002-01-16 07:02:57 richard Exp $ +# $Id: test_db.py,v 1.15 2002-01-19 13:16:04 rochecompaan Exp $ import unittest, os, shutil @@ -190,6 +190,55 @@ class anydbmDBTestCase(MyTestCase): ar(IndexError, self.db.issue.set, '1', title='foo', status='1', nosy=['10']) + def testJournals(self): + self.db.issue.addprop(fixer=Link("user", do_journal='yes')) + self.db.user.create(username="mary") + self.db.user.create(username="pete") + self.db.issue.create(title="spam", status='1') + self.db.commit() + + # journal entry for issue create + journal = self.db.getjournal('issue', '1') + self.assertEqual(1, len(journal)) + (nodeid, date_stamp, journaltag, action, params) = journal[0] + self.assertEqual(nodeid, '1') + self.assertEqual(journaltag, 'test') + self.assertEqual(action, 'create') + keys = params.keys() + keys.sort() + self.assertEqual(keys, ['deadline', 'fixer', 'foo', 'nosy', + 'status', 'title']) + self.assertEqual(None,params['deadline']) + self.assertEqual(None,params['fixer']) + self.assertEqual(None,params['foo']) + self.assertEqual([],params['nosy']) + self.assertEqual('1',params['status']) + self.assertEqual('spam',params['title']) + + # journal entry for link + journal = self.db.getjournal('user', '1') + self.assertEqual(1, len(journal)) + self.db.issue.set('1', fixer='1') + self.db.commit() + journal = self.db.getjournal('user', '1') + self.assertEqual(2, len(journal)) + (nodeid, date_stamp, journaltag, action, params) = journal[1] + self.assertEqual('1', nodeid) + self.assertEqual('test', journaltag) + self.assertEqual('link', action) + self.assertEqual(('issue', '1', 'fixer'), params) + + # journal entry for unlink + self.db.issue.set('1', fixer='2') + self.db.commit() + journal = self.db.getjournal('user', '1') + self.assertEqual(3, len(journal)) + (nodeid, date_stamp, journaltag, action, params) = journal[2] + self.assertEqual('1', nodeid) + self.assertEqual('test', journaltag) + self.assertEqual('unlink', action) + self.assertEqual(('issue', '1', 'fixer'), params) + def testRetire(self): pass @@ -285,6 +334,10 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.14 2002/01/16 07:02:57 richard +# . lots of date/interval related changes: +# - more relaxed date format for input +# # Revision 1.13 2002/01/14 02:20:15 richard # . changed all config accesses so they access either the instance or the # config attriubute on the db. This means that all config is obtained from