Code

fix property type check, and dont create items that have no properties
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 18 Feb 2003 06:15:21 +0000 (06:15 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 18 Feb 2003 06:15:21 +0000 (06:15 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1524 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi/client.py
test/test_cgi.py

index 10c0e8d89f2eecc8be7aadd25e5ee4747b3cb917..5ba910a5d8b41897404fcc2f29d989b67be3af85 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: client.py,v 1.93 2003-02-18 04:56:29 richard Exp $
+# $Id: client.py,v 1.94 2003-02-18 06:15:21 richard Exp $
 
 __doc__ = """
 WWW request handler (also used in the stand-alone server).
@@ -867,6 +867,9 @@ class Client:
         m = []
         for needed in order:
             props = all_props[needed]
+            if not props:
+                # nothing to do
+                continue
             cn, nodeid = needed
 
             if nodeid is not None and int(nodeid) > 0:
@@ -1309,8 +1312,8 @@ class Client:
                     value.append((m.group(1), m.group(2)))
 
                 # make sure the link property is valid
-                if (not isinstance(propdef, hyperdb.Multilink) and
-                        not isinstance(propdef, hyperdb.Link)):
+                if (not isinstance(propdef[propname], hyperdb.Multilink) and
+                        not isinstance(propdef[propname], hyperdb.Link)):
                     raise ValueError, '%s %s is not a link or '\
                         'multilink property'%(cn, propname)
 
@@ -1569,6 +1572,7 @@ class Client:
             cl = self.db.classes[cn]
             if not isinstance(cl, hyperdb.FileClass):
                 continue
+            # we also don't want to create FileClass items with no content
             if not props.get('content', ''):
                 del all_props[(cn, id)]
 
index 92db0e75371d2a116786fe279bc936cf8d5f9700..d8c49fb8b2ba0aff2109b833d2363775c10cbca9 100644 (file)
@@ -8,7 +8,7 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
-# $Id: test_cgi.py,v 1.10 2003-02-17 06:44:01 richard Exp $
+# $Id: test_cgi.py,v 1.11 2003-02-18 06:15:21 richard Exp $
 
 import unittest, os, shutil, errno, sys, difflib, cgi, re
 
@@ -435,6 +435,12 @@ class FormTestCase(unittest.TestCase):
         self.assertRaises(ValueError, self.parseForm,
             {'test-1@link@link': 'issue'})
 
+    def testLinkNotLink(self):
+        self.assertRaises(ValueError, self.parseForm,
+            {'test-1@link@boolean': 'issue-1'})
+        self.assertRaises(ValueError, self.parseForm,
+            {'test-1@link@string': 'issue-1'})
+
     def testBackwardsCompat(self):
         res = self.parseForm({':note': 'spam'}, 'issue')
         date = res[0][('msg', '-1')]['date']