On May 2, 2011, at 3:22 PM, Shishir Ramam wrote:
> I have URLRewriting in effect and within a function, want to redirect on 
> error. (in this case, I want to wrap around to first page when I reach the 
> end). 
> 
> 
> something along the lines of - 
> 
>     start_idx = int(request.args[0])
>     rows =   db.mymodel.select(limitby=(start_idx, start_idx+page_size))
>     if len(rows) == 0:
>         return redirect('/app_url/1')
>     else:
>         #whatever...
>         pass
> 
> 
> The  issue is that '/app_url' is getting mapped to the /a/c/f format - I'd 
> like to use the URL that the user sees. 
> I can obviously hard code it - but seems brittle and would appreciate any 
> help tell me what I am missing..
> 

It's not clear what you're trying to accomplish. If it's a self-redirect, then 
something like:

    start_idx = int(request.args[0])
    rows =   db.mymodel.select(limitby=(start_idx, start_idx+page_size))
    if len(rows) == 0:
        redirect(URL('thisfunction', args=['1']))
    else:
        #whatever...
        pass

Notice that redirect doesn't return, so there's no point in "return redirect".

Reply via email to