From: stefan Date: Thu, 19 Feb 2009 20:03:10 +0000 (+0000) Subject: Use canonical sort order for multilinks. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c784dbf065935968fd334499d6fbae150e304a5b;p=roundup.git Use canonical sort order for multilinks. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4142 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/cgi/form_parser.py b/roundup/cgi/form_parser.py index ae7ef17..cf6bb25 100755 --- a/roundup/cgi/form_parser.py +++ b/roundup/cgi/form_parser.py @@ -425,7 +425,9 @@ class FormParser: if entry not in existing: existing.append(entry) value = existing - value.sort() + # Sort the value in the same order used by + # Multilink.from_raw. + value.sort(key = lambda x: int(x)) elif value == '': # other types should be None'd if there's no value @@ -483,9 +485,13 @@ class FormParser: except IndexError, message: raise FormError(str(message)) - # make sure the existing multilink is sorted + # make sure the existing multilink is sorted. We must + # be sure to use the same sort order in all places, + # since we want to compare values with "=" or "!=". + # The canonical order (given in Multilink.from_raw) is + # by the numeric value of the IDs. if isinstance(proptype, hyperdb.Multilink): - existing.sort() + existing.sort(key = lambda x: int(x)) # "missing" existing values may not be None if not existing: