Code

Use canonical sort order for multilinks.
authorstefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 19 Feb 2009 20:03:10 +0000 (20:03 +0000)
committerstefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 19 Feb 2009 20:03:10 +0000 (20:03 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4142 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi/form_parser.py

index ae7ef17e1bae5d47f296125af870684346792b3e..cf6bb2548e1ba0338d06ec1f2890c04930a9af80 100755 (executable)
@@ -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: