summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb100fa)
raw | patch | inline | side by side (parent: fb100fa)
author | rochecompaan <rochecompaan@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sat, 19 Jan 2002 13:16:04 +0000 (13:16 +0000) | ||
committer | rochecompaan <rochecompaan@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sat, 19 Jan 2002 13:16:04 +0000 (13:16 +0000) |
or off.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@567 57a73879-2fb5-44c3-a270-3262357dd7e2
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@567 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/hyperdb.py | patch | blob | history | |
test/test_db.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 723fe167143f69809efdd4d46a15779ac65bebe2..e88610fb0edcebd8bbc1141741dab3389d935152 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
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 6551535e8cd734278511b306555819a7c8d072d5..15f5c80d217a47d666d6c61348c81ed9deda0ac5 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
# 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.
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)
"""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)
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([]):
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(''):
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([]):
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):
#
# $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 8e51e01d23cfc0c4c4f81d4a691eddccb8a13afe..9632d365a6dfd036e9df619434ffa0dcfbc4a6cb 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
# 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
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
#
# $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