Skip to content

Commit 2fe1995

Browse files
author
Richard Jones
committed
*** empty log message ***
1 parent de4cedd commit 2fe1995

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

doc/customizing.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.149 $
5+
:Version: $Revision: 1.150 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1848,6 +1848,12 @@ pretty Date properties - render the date as "dd Mon YYYY" (eg. "19
18481848
format (eg. "yesterday")
18491849
menu only on Link and Multilink properties - render a form select
18501850
list for this property
1851+
sorted only on Multilink properties - produce a list of the linked
1852+
items sorted by some property, for example::
1853+
1854+
python:context.files.sorted('creation')
1855+
1856+
Will list the files by upload date.
18511857
reverse only on Multilink properties - produce a list of the linked
18521858
items in reverse order
18531859
isset returns True if the property has been set to a value

roundup/cgi/templating.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,12 @@ def __getitem__(self, num):
16481648
value = self._value[num]
16491649
return HTMLItem(self._client, self._prop.classname, value)
16501650

1651+
def sorted(self, property):
1652+
''' Return this multilink sorted by the given property '''
1653+
value = list(self._value[num])
1654+
value.sort(lambda a,b:cmp(a[property], b[property]))
1655+
return value
1656+
16511657
def __contains__(self, value):
16521658
''' Support the "in" operator. We have to make sure the passed-in
16531659
value is a string first, not a HTMLProperty.

0 commit comments

Comments
 (0)