I am confused...  or missing something...

On Apr 29, 3:35 pm, Philip <[email protected]> wrote:
> I'm not sure the patch submittal process, nor am I confident that my
> solution is the best way to solve the issue, but I'd like to propose a
> solution.
>
> Problem:
> * Situation: SQLTABLE with orderby=True is used on a URL that includes
> any variable. For example, URL is myapp.com/init/default/invoices?
> customer=Fred, and we'll say the table has three columns, Invoice
> number, Date, and Amount.
> * Bug: If you then click on one of the column headers in the table to
> sort the table, for example Amount, the resulting URL that gets called
> loses the variable. In this example, the resulting URL is myapp.com/
> init/default/invoices?orderby=Amount.  We have lost the customer
> variable we passed to the original URL.

THe web is stateles;  two requests are not correlated - so I do not
understand why this is a bug...

response.vars holds all your responses from the client (browser) - it
is up to your application to do something reasonable (i.e. preserve
the value in a controller, if it's pertinent to the applicaiton).

I do not see how / why this should be imposed on SQLTABLE.... you
could certainly keep this in your table definition if you wanted....

Maybe I'm missing something...

- Yakro
> * Relevant code: In the code visible here 
> -http://www.web2py.com/examples/static/epydoc/web2py.gluon.sqlhtml-pys...,
> the problem code is on line 1091, " _href=th_link+'?orderby=' + c"
>
> Proposed Solution:
> I think this requires adding a parameter to SQLTABLE which holds the
> vars passed to the current URL. I'll call it :vars.  For simplicity,
> let's assume that vars always has the same form as request.vars, so
> that the canonical way of calling SQLTABLE in these circumstances in a
> controller is to add a parameter 'vars=request.vars'.  Since it only
> comes into play when orderby=True, we can insert a few lines in
> SQLTABLE as follows.  These lines would follow line 1089.
>
> var_url=''
> if length(vars) > 0:
>     for v in vars:
>         var_url += '&' + v + '=' + vars[v]
>
> Then line 1091 would be changed from "_href=th_link+'?orderby='+c" to
> _href=th_link+'?orderby=' + c + var_url
>
> Please let me know if there is a better way to submit patches or to
> ensure that a proposed patch such as this has no unintended side
> effects.  And, of course, if others have a better way of solving this
> problem, please speak up.
>
> Regards,
> Philip

Reply via email to