At 18:27 12/05/99 , benjamin.ryzman@easynet.fr wrote:
Hello from a new Zope user!
I'm currently playing with the idea of implementing a sort of Slashdot community in Zope. I've just started DTML scripting and External methods but my experience with python is limited.
I'd like to get a sequence of the DTML Documents in the current Folder *reverse* sorted by an attribute. Is there an easier way to do it than to write an External Method. I find it difficult to believe that the "in" tag gets a "sort" attribute but not an "rsort". Also I cannot use the python reverse() method in an expr since this method reverses in place (and thus returns None).
What I was going to do was: <!--#in expr="objectValues('DTML Document').reverse()" sort=entered_date--> ... <!--#/in--> which doesn't work.
With the following patch applied to lib/python/DocumentTemplate/DT_in.py 406a407,408
reverse=None
413c415 < previous=1, next=1, expr='', sort='') ---
previous=1, next=1, expr='', sort='', reverse=1)
419a422,423
if has_key('reverse'): self.reverse=args['reverse']
484a489
if self.reverse is not None: sequence.reverse()
635a641
if self.reverse is not None: sequence.reverse()
This diff works on both Zope 1.10.2 and 1.11.0pr1 You can then use the following DTML:
<!--#in expr="objectValues('DTML Document')" sort=entered_date reverse--> ... <!--#/in-->
It basically adds a new attribute to the #in tag, called 'reverse'. If present, the sequence will be reversed, wether it is sorted or not. This way it is also usable on sequences that have been sorted already. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------