From: richard Date: Wed, 8 Jan 2003 04:33:56 +0000 (+0000) Subject: handle :add: better in cgi form parsing (sf bug 663235) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0ae2ea5bdf5ec4dc7abc72628924faf0141a265b;p=roundup.git handle :add: better in cgi form parsing (sf bug 663235) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1423 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 171bd3e..9f75e69 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,7 @@ are given with the most recent entry first. (multipart/alternative, "fw" and content-type "name") - fire auditors and reactors in rdbms retire (thanks Sheila King) - better match for mailgw help "command" text +- handle :add: better in cgi form parsing (sf bug 663235) 2002-12-11 0.5.3 diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 856bad8..cd85e63 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.63 2002-12-15 23:55:33 richard Exp $ +# $Id: client.py,v 1.64 2003-01-08 04:33:56 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -1188,7 +1188,7 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): # does the property exist? if not properties.has_key(propname): - if mlaction != 'set': + if mlaction == 'remove': raise ValueError, 'You have submitted a remove action for'\ ' the property "%s" which doesn\'t exist'%propname continue @@ -1198,8 +1198,18 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): # of MiniFieldStorages. value = form[key] - # make sure non-multilinks only get one value - if not isinstance(proptype, hyperdb.Multilink): + # handle unpacking of the MiniFieldStorage / list form value + if isinstance(proptype, hyperdb.Multilink): + # multiple values are OK + if isinstance(value, type([])): + # it's a list of MiniFieldStorages + value = [i.value.strip() for i in value] + else: + # it's a MiniFieldStorage, but may be a comma-separated list + # of values + value = [i.strip() for i in value.value.split(',')] + else: + # multiple values are not OK if isinstance(value, type([])): raise ValueError, 'You have submitted more than one value'\ ' for the %s property'%propname @@ -1258,16 +1268,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): 'for property "%(propname)s": %(message)s')%{ 'propname': propname, 'message': message} elif isinstance(proptype, hyperdb.Multilink): - if isinstance(value, type([])): - # it's a list of MiniFieldStorages - value = [i.value.strip() for i in value] - else: - # it's a MiniFieldStorage, but may be a comma-separated list - # of values - value = [i.strip() for i in value.value.split(',')] + # perform link class key value lookup if necessary link = proptype.classname l = [] - for entry in map(str, value): + for entry in value: if entry == '': continue if not num_re.match(entry): try: