[Zope] sequence.sort on a property of contained objects

Hong Yuan obichina at 21cn.com
Sat Oct 9 10:13:45 EDT 2004


Hi,

I have several zope folders on the FSDV and I want to display their 
titles in a certain order with a ZPT.

Since folders on FSDV can not have property of their own, I created a FS 
property object, whose id is 'property', in each of the folders. And 
each 'property' objects contains a property 'menu_order', according to 
which the folders should be sorted.

I try to use the following code to sort the folders:
<ul tal:define="folders here/get_folders;
                  sort_on python:(('property/menu_order', 'cmp', 'asc'),);
                  sorted_folders python:sequence.sort(folders, sort_on)">

But it seems the sort condition can not contain path expression to 
access 'property/menu_order'. It takes the whole as a property of the 
folder object and wouldn't treat 'property' as an object contained in 
the folder and get its property 'menu_order'. As a result, no sort is 
performed.

Is there any solution to this except for writing a custom sort function 
of my own?

Thanks,
Hong Yuan


More information about the Zope mailing list