> On Mon, May 3, 2010 at 11:08 PM, Jonathan Lundell <jlund...@pobox.com> wrote: > web2py probably isn't setting referer on a redirect, and if it did, you'd > have to interpret the URL. > > No. If I have no redirect and call a location with no args the referer is not > set when I arrive at web2py's default "Internal error" page. Which is okay > because the standard says referer is optionally set by the client. > > > How about putting the previous location in session before you redirect? > > That works on some instances, but not for controlling for the wrong number or > the wrong parameters. A concrete example: > > 1. Currently in www.domain.com/a/c/f/arg1 > 2. User edits address bar and presses enter (removed arg1): > www.domain.com/a/c/f/ > 3. The called action: > > def f(): > if not request.args: > > redirect(request.last_location) # including args > > Perhaps someone knows of an alternative way to accomplish the same?
The session is pretty much the only place you've got to keep information between pages. In the above example, in step 1, you need to save the current location in session. You can do that in f() before you return, or if you want to always do it (from every c/f), you could perhaps do it in your layout.html: copy the location from request to session. (That won't work for redirects, but you might not want it to.)