[Zope] Sort in tree tag

Oliver Bleutgen Oliver Bleutgen <myzope@gmx.net>
Mon, 15 Oct 2001 15:13:37 +0200


>> write a small script (python),
>>
>> get_index
>> try:
>>     my_index = context.index
>> except:
>>     my_index = 0
>> return my_index

>> now with
>> <tree .. sort=get_index>

> I did it with plain DTML:

> <dtml-if "_.hasattr(aq_explicit,'dirIndex')"><dtml-return dirIndex>
> <dtml-else><dtml-return "0">
> </dtml-if>

> but didn't work. No error, but also no correct sorting. The order of
> things is different from that when using no sort= attribute, but I
> couldn't figure out what kind of order it is :-(

> Even when I just return the id in my dtml method, where you would expect
> tree-tag to sort things by id, it doesn't do the sort correctly.

> So, anybody an idea what's going on here?

First, obvious question, why don't you try the python
script? Just tried it, it works (for me).

As for your dtml-approach, no idea why it doesn't 
work, but I can indeed confirm this.

Perhaps a sign?

"Thou shalt not abuse dtml for pure logic, for
it will cometh back and bite you" ;-)

cheers,
oliver