I have a Dojo DataGrid fed by a json response at
http://localhost/json/You can sort this DataGrid by any column. When I tell the DataGrid I want to sort by, say sticker_id, the DataGrid sends another request to /json/?sort(+sticker_id).
Currently, I am handling this by pulling the parameter name from web.input() (since there is no value) and parsing it like so:
s = "sort(+sticker_id)" # String after retrieval of parameter
s = s[5:-1] # s == "+sticker_id"
if s[0] == '+'
order_by = s[1:] + " ASC"
if s[0] == '-'
order_by = s[1:] + " DESC"
then I run something like db.select("myTable" order=order_by)
and eventually json dump the data.
Does it work? Yes. But I feel like there is a better and more pythonic way to do this. Does anyone have any tips to point me in the right direction?