@@ -1637,7 +1637,9 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16371637 "additional" lists properties which should be included in the
16381638 label
16391639 "sort_on" indicates the property to sort the list on as
1640- (direction, property) where direction is '+' or '-'.
1640+ (direction, property) where direction is '+' or '-'. A
1641+ single string with the direction prepended may be used.
1642+ For example: ('-', 'order'), '+name'.
16411643
16421644 The remaining keyword arguments are used as conditions for
16431645 filtering the items in the list - they're passed as the
@@ -1657,13 +1659,16 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16571659 if value is None :
16581660 s = 'selected="selected" '
16591661 l .append (self ._ ('<option %svalue="-1">- no selection -</option>' )% s )
1660- if linkcl .getprops ().has_key ('order' ):
1662+ if sort_on is not None :
1663+ if not isinstance (sort_on , tuple ):
1664+ if sort_on [0 ] in '+-' :
1665+ sort_on = (sort_on [0 ], sort_on [1 :])
1666+ else :
1667+ sort_on = ('+' , sort_on )
1668+ elif linkcl .getprops ().has_key ('order' ):
16611669 sort_on = ('+' , 'order' )
16621670 else :
1663- if sort_on is None :
1664- sort_on = ('+' , linkcl .labelprop ())
1665- else :
1666- sort_on = ('+' , sort_on )
1671+ sort_on = ('+' , linkcl .labelprop ())
16671672 options = linkcl .filter (None , conditions , sort_on , (None , None ))
16681673
16691674 # make sure we list the current value if it's retired
0 commit comments