Skip to content

Commit 681eb52

Browse files
author
Richard Jones
committed
fix property type check, and dont create items that have no properties
1 parent 3a9e955 commit 681eb52

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

roundup/cgi/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.93 2003-02-18 04:56:29 richard Exp $
1+
# $Id: client.py,v 1.94 2003-02-18 06:15:21 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -867,6 +867,9 @@ def _editnodes(self, all_props, all_links, newids=None):
867867
m = []
868868
for needed in order:
869869
props = all_props[needed]
870+
if not props:
871+
# nothing to do
872+
continue
870873
cn, nodeid = needed
871874

872875
if nodeid is not None and int(nodeid) > 0:
@@ -1309,8 +1312,8 @@ class <designator> (where <designator> must be
13091312
value.append((m.group(1), m.group(2)))
13101313

13111314
# make sure the link property is valid
1312-
if (not isinstance(propdef, hyperdb.Multilink) and
1313-
not isinstance(propdef, hyperdb.Link)):
1315+
if (not isinstance(propdef[propname], hyperdb.Multilink) and
1316+
not isinstance(propdef[propname], hyperdb.Link)):
13141317
raise ValueError, '%s %s is not a link or '\
13151318
'multilink property'%(cn, propname)
13161319

@@ -1569,6 +1572,7 @@ class <designator> (where <designator> must be
15691572
cl = self.db.classes[cn]
15701573
if not isinstance(cl, hyperdb.FileClass):
15711574
continue
1575+
# we also don't want to create FileClass items with no content
15721576
if not props.get('content', ''):
15731577
del all_props[(cn, id)]
15741578

test/test_cgi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_cgi.py,v 1.10 2003-02-17 06:44:01 richard Exp $
11+
# $Id: test_cgi.py,v 1.11 2003-02-18 06:15:21 richard Exp $
1212

1313
import unittest, os, shutil, errno, sys, difflib, cgi, re
1414

@@ -435,6 +435,12 @@ def testLinkBadDesignator(self):
435435
self.assertRaises(ValueError, self.parseForm,
436436
{'test-1@link@link': 'issue'})
437437

438+
def testLinkNotLink(self):
439+
self.assertRaises(ValueError, self.parseForm,
440+
{'test-1@link@boolean': 'issue-1'})
441+
self.assertRaises(ValueError, self.parseForm,
442+
{'test-1@link@string': 'issue-1'})
443+
438444
def testBackwardsCompat(self):
439445
res = self.parseForm({':note': 'spam'}, 'issue')
440446
date = res[0][('msg', '-1')]['date']

0 commit comments

Comments
 (0)