Skip to content

Commit fd82fa8

Browse files
author
Alexander Smishlajev
committed
ignore sorting errors in MultilinkHTMLProperty instantiation [SF#1177602]
1 parent b117f8f commit fd82fa8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

roundup/cgi/templating.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16221622
label
16231623
"sort_on" indicates the property to sort the list on as
16241624
(direction, property) where direction is '+' or '-'.
1625-
1625+
16261626
The remaining keyword arguments are used as conditions for
16271627
filtering the items in the list - they're passed as the
16281628
"filterspec" argument to a Class.filter() call.
@@ -1698,10 +1698,17 @@ class MultilinkHTMLProperty(HTMLProperty):
16981698
def __init__(self, *args, **kwargs):
16991699
HTMLProperty.__init__(self, *args, **kwargs)
17001700
if self._value:
1701-
self._value = lookupIds(self._db, self._prop, self._value,
1701+
display_value = lookupIds(self._db, self._prop, self._value,
17021702
fail_ok=1)
17031703
sortfun = make_sort_function(self._db, self._prop.classname)
1704-
self._value.sort(sortfun)
1704+
# sorting fails if the value contains
1705+
# items not yet stored in the database
1706+
# ignore these errors to preserve user input
1707+
try:
1708+
display_value.sort(sortfun)
1709+
except:
1710+
pass
1711+
self._value = display_value
17051712

17061713
def __len__(self):
17071714
''' length of the multilink '''
@@ -1794,7 +1801,7 @@ def menu(self, size=None, height=None, showid=0, additional=[],
17941801
label
17951802
"sort_on" indicates the property to sort the list on as
17961803
(direction, property) where direction is '+' or '-'.
1797-
1804+
17981805
The remaining keyword arguments are used as conditions for
17991806
filtering the items in the list - they're passed as the
18001807
"filterspec" argument to a Class.filter() call.

0 commit comments

Comments
 (0)