Skip to content

Commit 4e42652

Browse files
committed
Use canonical sort order for multilinks.
1 parent 522d6f9 commit 4e42652

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

roundup/cgi/form_parser.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@ def parse(self, create=0, num_re=re.compile('^\d+$')):
425425
if entry not in existing:
426426
existing.append(entry)
427427
value = existing
428-
value.sort()
428+
# Sort the value in the same order used by
429+
# Multilink.from_raw.
430+
value.sort(key = lambda x: int(x))
429431

430432
elif value == '':
431433
# other types should be None'd if there's no value
@@ -483,9 +485,13 @@ def parse(self, create=0, num_re=re.compile('^\d+$')):
483485
except IndexError, message:
484486
raise FormError(str(message))
485487

486-
# make sure the existing multilink is sorted
488+
# make sure the existing multilink is sorted. We must
489+
# be sure to use the same sort order in all places,
490+
# since we want to compare values with "=" or "!=".
491+
# The canonical order (given in Multilink.from_raw) is
492+
# by the numeric value of the IDs.
487493
if isinstance(proptype, hyperdb.Multilink):
488-
existing.sort()
494+
existing.sort(key = lambda x: int(x))
489495

490496
# "missing" existing values may not be None
491497
if not existing:

0 commit comments

Comments
 (0)