Re: [Zope] ASC / DESC in queries`?
Jan Johansson wrote:
Just do not pass any part of the actual SQL you will use in REQUEST, and you should be fine. Probably easiest in this case would be to pass a flag that means ascending, then use some dtml in your ZSQL Method like this, or something similar:
<dtml-if sort_order_asc>ASC<dtml-else>DESC</dtml-if>
Aaaah, never thought about that, simple solution too. Uhm, now comes a real newbie question tho. How do i "unset" a variable? I must be blind in my Zope Book and assorted online resources. What i am trying to do is a simple "sort ASC/DESC" toggle on a sql-result page.
Please keep your questions on the list to help others. I would set it to a zero-length string. Zope handles the following OK on my machine. <a href="<dtml-var URL0>?sort_order_asc=1">ascending</a> <a href="<dtml-var URL0>?sort_order_asc=">descending</a> -- Jim Washington
[Jim Washington]
I would set it to a zero-length string. Zope handles the following OK on my machine.
<a href="<dtml-var URL0>?sort_order_asc=1">ascending</a> <a href="<dtml-var URL0>?sort_order_asc=">descending</a>
Better to have it be ...sort_order_asc=0 so that you can be sure that the property exists. You can still test it easily using dtml-if. Otherwise the test may fail because the property does not exist. Cheers, Tom P
Thomas B. Passin wrote:
[Jim Washington]
I would set it to a zero-length string. Zope handles the following OK on my machine.
<a href="<dtml-var URL0>?sort_order_asc=1">ascending</a> <a href="<dtml-var URL0>?sort_order_asc=">descending</a>
Better to have it be ...sort_order_asc=0 so that you can be sure that the property exists. You can still test it easily using dtml-if. Otherwise the test may fail because the property does not exist.
I thought that too, then tested it. ...sort_order_asc=0 returns a string, '0', which tests true. The dtml we were working with just tested existence or truth, <dtml-if sort_order_asc>, so sending an empty string in this case works better, unless one really wants to go through the trouble of checking for existence, then doing an _.int on it or running it through <dtml-try>. Unless, of course, it is invalid HTML, which I haven't checked. :) -- Jim Washington
[Jim Washington]
Thomas B. Passin wrote:
[Jim Washington]
I would set it to a zero-length string. Zope handles the following OK on my machine.
<a href="<dtml-var URL0>?sort_order_asc=1">ascending</a> <a href="<dtml-var URL0>?sort_order_asc=">descending</a>
Better to have it be ...sort_order_asc=0 so that you can be sure that the property exists. You can still test it easily using dtml-if. Otherwise the test may fail because the property does not exist.
I thought that too, then tested it. ...sort_order_asc=0 returns a string, '0', which tests true. The dtml we were working with just tested existence or truth, <dtml-if sort_order_asc>, so sending an empty string in this case works better, unless one really wants to go through the trouble of checking for existence, then doing an _.int on it or running it through <dtml-try>.
Unless, of course, it is invalid HTML, which I haven't checked. :)
Well, well, I tried it too and got your result. Good to know. Tom P
On Tuesday, February 26, 2002, at 02:59 PM, Thomas B. Passin wrote:
Better to have it be ...sort_order_asc=0 so that you can be sure that
Or you could use sort_order_asc:int=0, and it will marshal as an int automatically! -steve
participants (3)
-
Jim Washington -
Steve Spicklemire -
Thomas B. Passin