diff roundup/cgi/templating.py @ 3270:e4607e12d030

ignore sorting errors in MultilinkHTMLProperty instantiation [SF#1177602]
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Thu, 07 Apr 2005 07:06:24 +0000
parents 34d034a4c0d9
children 572bbe7fa236
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Thu Apr 07 06:38:38 2005 +0000
+++ b/roundup/cgi/templating.py	Thu Apr 07 07:06:24 2005 +0000
@@ -1622,7 +1622,7 @@
                 label
             "sort_on" indicates the property to sort the list on as
                 (direction, property) where direction is '+' or '-'.
-            
+
             The remaining keyword arguments are used as conditions for
             filtering the items in the list - they're passed as the
             "filterspec" argument to a Class.filter() call.
@@ -1698,10 +1698,17 @@
     def __init__(self, *args, **kwargs):
         HTMLProperty.__init__(self, *args, **kwargs)
         if self._value:
-            self._value = lookupIds(self._db, self._prop, self._value,
+            display_value = lookupIds(self._db, self._prop, self._value,
                 fail_ok=1)
             sortfun = make_sort_function(self._db, self._prop.classname)
-            self._value.sort(sortfun)
+            # sorting fails if the value contains
+            # items not yet stored in the database
+            # ignore these errors to preserve user input
+            try:
+                display_value.sort(sortfun)
+            except:
+                pass
+            self_value = display_value
 
     def __len__(self):
         ''' length of the multilink '''
@@ -1794,7 +1801,7 @@
                 label
             "sort_on" indicates the property to sort the list on as
                 (direction, property) where direction is '+' or '-'.
-            
+
             The remaining keyword arguments are used as conditions for
             filtering the items in the list - they're passed as the
             "filterspec" argument to a Class.filter() call.

Roundup Issue Tracker: http://roundup-tracker.org/