summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e142036)
raw | patch | inline | side by side (parent: e142036)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 23 Aug 2002 05:33:32 +0000 (05:33 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 23 Aug 2002 05:33:32 +0000 (05:33 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@993 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/backends/back_gadfly.py | patch | blob | history | |
test/test_db.py | patch | blob | history |
index ccf42dcc5a18f0fb74660b2613773bb2df5df140..d0d21106a97e1dc68bbba640cb8480bcf93cfde7 100644 (file)
-# $Id: back_gadfly.py,v 1.4 2002-08-23 05:00:38 richard Exp $
+# $Id: back_gadfly.py,v 1.5 2002-08-23 05:33:32 richard Exp $
__doc__ = '''
About Gadfly
============
# make sure we do the commit-time extra stuff for this node
self.transactions.append((self.doSaveNode, (classname, nodeid, node)))
- def setnode(self, classname, nodeid, node):
+ def setnode(self, classname, nodeid, node, multilink_changes):
''' Change the specified node.
'''
if __debug__:
cursor.execute(sql, vals)
# now the fun bit, updating the multilinks ;)
- # XXX TODO XXX
+ for col, (add, remove) in multilink_changes.items():
+ tn = '%s_%s'%(classname, col)
+ if add:
+ sql = 'insert into %s (nodeid, linkid) values (?,?)'%tn
+ vals = [(nodeid, addid) for addid in add]
+ if __debug__:
+ print >>hyperdb.DEBUG, 'setnode (add)', (self, sql, vals)
+ cursor.execute(sql, vals)
+ if remove:
+ sql = 'delete from %s where nodeid=? and linkid=?'%tn
+ vals = [(nodeid, removeid) for removeid in remove]
+ if __debug__:
+ print >>hyperdb.DEBUG, 'setnode (rem)', (self, sql, vals)
+ cursor.execute(sql, vals)
# make sure we do the commit-time extra stuff for this node
self.transactions.append((self.doSaveNode, (classname, nodeid, node)))
# if the journal value is to be different, store it in here
journalvalues = {}
+ # remember the add/remove stuff for multilinks, making it easier
+ # for the Database layer to do its stuff
+ multilink_changes = {}
+
for propname, value in propvalues.items():
# check to make sure we're not duplicating an existing key
if propname == self.key and node[propname] != value:
l.append(('+', add))
if remove:
l.append(('-', remove))
+ multilink_changes[propname] = (add, remove)
if l:
journalvalues[propname] = tuple(l)
return propvalues
# do the set, and journal it
- self.db.setnode(self.classname, nodeid, node)
+ self.db.setnode(self.classname, nodeid, node, multilink_changes)
if self.do_journal:
propvalues.update(journalvalues)
#
# $Log: not supported by cvs2svn $
+# Revision 1.4 2002/08/23 05:00:38 richard
+# fixed read-only gadfly retire()
+#
# Revision 1.3 2002/08/23 04:58:00 richard
# ahhh, I understand now
#
diff --git a/test/test_db.py b/test/test_db.py
index eabede4b6c74c8c093881e6cfc41222ebffbde44..88330eca4b415cda16cdaf411dfbd921688d5ce7 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.41 2002-08-23 04:58:00 richard Exp $
+# $Id: test_db.py,v 1.42 2002-08-23 05:33:32 richard Exp $
import unittest, os, shutil, time
self.db.issue.set('1', status=None)
self.assertEqual(self.db.issue.get('1', "status"), None)
+ def testMultilinkChange(self):
+ u1 = self.db.user.create(username='foo')
+ u2 = self.db.user.create(username='bar')
+ self.db.issue.create(title="spam", nosy=[u1])
+ self.assertEqual(self.db.issue.get('1', "nosy"), [u1])
+ self.db.issue.set('1', nosy=[])
+ self.assertEqual(self.db.issue.get('1', "nosy"), [])
+ self.db.issue.set('1', nosy=[u1,u2])
+ self.assertEqual(self.db.issue.get('1', "nosy"), [u1,u2])
+
def testDateChange(self):
self.db.issue.create(title="spam", status='1')
a = self.db.issue.get('1', "deadline")