Sort variable within the 'IN' tag
Hey there, Is there any way of using a variable passed through on the query string to specify what the in command is sorted on, i just get an error if i try to use any type of variable... Any help would be appreciated, Cheers, Phil. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
You can use the sort option. For instance: <!--# in "objectValues(['DTML Document'])" sort=title --> will iterate over all DTML Documents in the folder sorted by title Pavlos On Mon, 19 Apr 1999, Wombat Harness the Third wrote:
Hey there,
Is there any way of using a variable passed through on the query string to specify what the in command is sorted on, i just get an error if i try to use any type of variable...
Any help would be appreciated,
Cheers,
Phil.
______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(For developer-specific issues, use the companion list, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
At 04:02 PM 4/19/99 GMT, Wombat Harness wrote:
Is there any way of using a variable passed through on the query string to specify what the in command is sorted on, i just get an error if i try to use any type of variable...
I think that I ran up against this limitation a while ago too. Basically some tag arguments accept literals, some that accept names of variables, and others accept expressions. The general rhythm, which seems a bit annoying, is to have two attributes if you want both kinds of access. So you could modify the 'in' tag to have a 'sort_expr' attribute as well as a 'sort' attribute. If you want to take a crack at it, the file to modify is lib/python/DocumentTemplate/DT_In.py (Hey while you're at it how about a 'reverse' attribute which reverses the list when set to true ;-) It might be nice to find some way around this need for double attributes. Perhaps all tag attributes should accept expressions. Or maybe there could be a special way to spell an expression when a literal is expected... Maybe the still undocumented DTML tag framework needs a tune up. I'm not sure what the answer is, but it seems like things could be cleaner and more flexible. -Amos
Thanks Amos for reading the posted questions more carefully than I do. Another limitation/feature I encountered when using the sort option is that if any of the iterated objects does not contain the attribute specified with the sort option then an error is raised. It would be nice if there was an option to skip such objects. Does anyone know of way to do this in simple DTML? Until now I have been using external methods to filter out inappropriate entries. Pavlos On Mon, 19 Apr 1999, Amos Latteier wrote:
At 04:02 PM 4/19/99 GMT, Wombat Harness wrote:
Is there any way of using a variable passed through on the query string to specify what the in command is sorted on, i just get an error if i try to use any type of variable...
I think that I ran up against this limitation a while ago too. Basically some tag arguments accept literals, some that accept names of variables, and others accept expressions. The general rhythm, which seems a bit annoying, is to have two attributes if you want both kinds of access. So you could modify the 'in' tag to have a 'sort_expr' attribute as well as a 'sort' attribute.
If you want to take a crack at it, the file to modify is lib/python/DocumentTemplate/DT_In.py
(Hey while you're at it how about a 'reverse' attribute which reverses the list when set to true ;-)
It might be nice to find some way around this need for double attributes. Perhaps all tag attributes should accept expressions. Or maybe there could be a special way to spell an expression when a literal is expected... Maybe the still undocumented DTML tag framework needs a tune up. I'm not sure what the answer is, but it seems like things could be cleaner and more flexible.
-Amos
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(For developer-specific issues, use the companion list, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
Thanks Amos for reading the posted questions more carefully than I do.
Another limitation/feature I encountered when using the sort option is that if any of the iterated objects does not contain the attribute specified with the sort option then an error is raised. It would be nice if there was an option to skip such objects. Does anyone know of way to do this in simple DTML? Until now I have been using external methods to filter out inappropriate entries.
Pavlos
In the same vein, if you do <!--#in spam sort=title mapping --> ZT will look for spam[x].title, instead of spam[x]['title'], as the mapping keyword implies.
participants (4)
-
Amos Latteier -
Pavlos Christoforou -
Quinn Dunkan -
Wombat Harness the Third