[Zope] sort based on a variable

Michael Guerrero mguerrero@tachyon.net
Mon, 17 Mar 2003 14:08:03 -0800


This is a multi-part message in MIME format.

------_=_NextPart_001_01C2ECD1.AE00F36A
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have a table tab1 with 3 columns col1,co2,col3.
=20
I've defined a sql method 'get_list' as 'select col1,co2,col3 from tab1.
=20
In a dtml method (view_list)I want call get_list and sort on any of the =
three columns.  I know I can do the following:
=20
<dtml-in get_list sort=3D"col2">
   display stuff here
</dtml-in>
=20
I'm passing the sort order column to view_list using -->  =
view_list?sort_order=3Dcol2
=20
I get no error but incorrect results when I try to do the following in =
view_list:
<dtml-call "REQUEST.set('t_sort_order',sort_order)">
<dtml-in sql_list_rma sort=3Dt_sort_order>
=20
I also tried putting various combinations of single and double quotes =
around t_sort_order' without any luck.
=20
I can display t_sort_order, so I know it's getting the proper value.  It =
just doesn't evaluate correctly.  I think it has something with =
double-quotes needing to surround the sort filename.
=20
I really don't want to create 3 sql methods =
(get_list_by_col1,get_list_by_col2,get_list_by_col3).
=20
I'd appreciate any help.
=20
Thanks.
=20
Mike Guerrero


------_=_NextPart_001_01C2ECD1.AE00F36A
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I have =
a table=20
tab1&nbsp;with 3 columns col1,co2,col3.</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I've =
defined a sql=20
method 'get_list' as 'select&nbsp;col1,co2,col3 from =
tab1.</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>In a =
dtml method=20
(view_list)I want call get_list and sort on any of the three =
columns.&nbsp; I=20
know I can do the following:</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial =
size=3D2>&lt;dtml-in get_list=20
sort=3D"col2"&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial =
size=3D2>&nbsp;&nbsp; display=20
stuff here</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2>&lt;/dtml-in&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I'm =
passing the sort=20
order column to view_list using --&gt;&nbsp;=20
view_list?sort_order=3Dcol2</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I get =
no error but=20
incorrect results when I try to do the following in=20
view_list:</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial =
size=3D2>&lt;dtml-call=20
"REQUEST.set('t_sort_order',sort_order)"&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003></SPAN><SPAN =
class=3D725275121-17032003><FONT=20
face=3DArial size=3D2>&lt;dtml-in sql_list_rma=20
sort=3Dt_sort_order&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I also =
tried putting=20
various combinations of single and double quotes around=20
t_sort_order'&nbsp;without any luck.</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I can =
display=20
t_sort_order, so I know it's getting the proper value.&nbsp; It just =
doesn't=20
evaluate correctly.&nbsp; I think it has something with double-quotes =
needing to=20
surround the sort filename.</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I =
really don't want=20
to create 3 sql methods=20
(get_list_by_col1,get_list_by_col2,get_list_by_col3).</FONT></SPAN></DIV>=

<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>I'd =
appreciate any=20
help.</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2>Thanks.</FONT></SPAN></DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D725275121-17032003><FONT face=3DArial size=3D2>Mike =
Guerrero</DIV>
<DIV><BR></DIV></FONT></SPAN><SPAN class=3D725275121-17032003><FONT =
face=3DArial=20
size=3D2></FONT></SPAN></BODY></HTML>

------_=_NextPart_001_01C2ECD1.AE00F36A--