Mercurial > p > roundup > code
comparison roundup/cgi/form_parser.py @ 4050:a412ce8ccf6f
Use canonical sort order for multilinks.
| author | Stefan Seefeld <stefan@seefeld.name> |
|---|---|
| date | Thu, 19 Feb 2009 20:03:10 +0000 |
| parents | c9a8a47c4666 |
| children | ab4563e97d22 |
comparison
equal
deleted
inserted
replaced
| 4049:c9a8a47c4666 | 4050:a412ce8ccf6f |
|---|---|
| 423 # add - easy, just don't dupe | 423 # add - easy, just don't dupe |
| 424 for entry in l: | 424 for entry in l: |
| 425 if entry not in existing: | 425 if entry not in existing: |
| 426 existing.append(entry) | 426 existing.append(entry) |
| 427 value = existing | 427 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)) | |
| 429 | 431 |
| 430 elif value == '': | 432 elif value == '': |
| 431 # other types should be None'd if there's no value | 433 # other types should be None'd if there's no value |
| 432 value = None | 434 value = None |
| 433 else: | 435 else: |
| 481 if not propdef.has_key(propname): | 483 if not propdef.has_key(propname): |
| 482 raise | 484 raise |
| 483 except IndexError, message: | 485 except IndexError, message: |
| 484 raise FormError(str(message)) | 486 raise FormError(str(message)) |
| 485 | 487 |
| 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. | |
| 487 if isinstance(proptype, hyperdb.Multilink): | 493 if isinstance(proptype, hyperdb.Multilink): |
| 488 existing.sort() | 494 existing.sort(key = lambda x: int(x)) |
| 489 | 495 |
| 490 # "missing" existing values may not be None | 496 # "missing" existing values may not be None |
| 491 if not existing: | 497 if not existing: |
| 492 if isinstance(proptype, hyperdb.String): | 498 if isinstance(proptype, hyperdb.String): |
| 493 # some backends store "missing" Strings as empty strings | 499 # some backends store "missing" Strings as empty strings |
