From: richard Date: Tue, 18 Feb 2003 06:15:21 +0000 (+0000) Subject: fix property type check, and dont create items that have no properties X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c1036bd5eaf979c0fcfd17898bfaaa064fe91ce1;p=roundup.git fix property type check, and dont create items that have no properties git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1524 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 10c0e8d..5ba910a 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -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)] diff --git a/test/test_cgi.py b/test/test_cgi.py index 92db0e7..d8c49fb 100644 --- a/test/test_cgi.py +++ b/test/test_cgi.py @@ -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']