[Zope] #tree & reverse sort
Martijn Pieters
mj@antraciet.nl
Wed, 08 Sep 1999 14:55:30 +0200
At 13:55 08/09/99 , Achim Gorski wrote:
>Hello Zope users!
>
>
>The following construct works in Zope-2.0.0b6:
><!--#tree dox leaves="objectValues(['Folder', 'DTML Document'])" sort=id
>reverse-->
>
>I've now switched to Zope-2.0.0 and the above reverse sort produces an
>AttributeError. I still can do reverse sort with the #in tag!
>What's different in 2.0.0 or how can I do a reverse sort with the #tree tag??
>
>Thanks for your advice.
>
>- Achim
Congratulations, you have found a bug,
When Chris subtly changed the way the reverse is performed in both in and
tree tags, he made a mistake in the tree tag, and must have missed it.
The Tree class uses two TreeDisplay Module functions (note: not member
methods of the Tree class) to display your tree, and within those functions
'self' is the same as the _.this() object. In case of a DTML Method, it's
the Method's parent in the acquisition path.
Chris, however, thought it would be the Tree class itself. That class has a
new method, reverse_items, which he thought he could call with
self.reverse_items. What happens is that that method is looked up in your
acquisition tree, where it is not present.
Solution:
Remove the reverse_tems method at line 158 and change
items=self.reverse_items(items) (line 345) to:
items=list(items)
items.reverse()
Warning: I did not test this, but I am sure it'll work.
I'll report this to the Collector.
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------