On Apr 29, 2010, at 2:06 PM, Philip wrote:

> Thadeus,
> I have noticed the same bug in appadmin, but unfortunately I do not
> believe this will help resolve that bug.

If you put the orderby in request.vars, then the next-page logic will be able 
to use it to do the right thing (caveat: I'm not looking at the code).

> -Philip
> 
> On Apr 29, 4:49 pm, Jonathan Lundell <jlund...@pobox.com> wrote:
>> On Apr 29, 2010, at 1:43 PM, Thadeus Burgess wrote:
>> 
>>> There is also a bug in appadmin that when you sort you get the list
>>> sorted, but if you browse the next 100 records, the sorting reverses
>>> itself. Do you think this would fix that bug as well?
>> 
>> Perhaps what you want to do is to append orderby=c to request.vars, and 
>> generate the URL from there.
>> 
>> Also, vars wants to be encoded. This is the logic from html.URL:
>> 
>>          '?%s' % urllib.urlencode(vars)
>> 
>> It's not needed in the current code because we know a priori that there's 
>> nothing to encode. But that's not true if we include request.vars.
>> 
>> 
>> 
>> 
>> 
>>> --
>>> Thadeus
>> 
>>> On Thu, Apr 29, 2010 at 3:35 PM, Philip <philip.el...@gmail.com> 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.
>>>> * 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