[mod_python] Detecting Back Button Usage

Jorey Bump list at joreybump.com
Tue Mar 20 09:30:19 EST 2007

Clodoaldo wrote:
> 2007/3/20, Kenneth Loafman <kenneth at loafman.com>:
>> The problem comes in the use of the back button.  The browser merely
>> displays the last page rather than rebuilding it, or at least restoring
>> the variables.  
> How does the user select the point? Entering it in a form field? If so
> save the plot values (the page state) on the page using a hidden field
> inside the form:
> <input type="hidden" name="variable_1" value="99.9">
> <input type="hidden" name="variable_2" value="33.3">
> When the form is submitted those values will be available to your script.

These days, all bets are off concerning the default behaviour of the 
back button on the variety of browsers one will encounter. There's no 
way to enforce sending form variables without client side scripting...

> If you are using some Ajax scripting to let the user select the point
> then adapt it to also send the current page state.

...as you suggest here. Even so, exhaustive testing is recommended 
before you assume it works for all browsers, as well as preparing for 
browsers with DHTML features disabled or crippled. The most foolproof 
design will maintain state on the server, perhaps using a database. It's 
  a lot of work up front, but has a number of payoffs, as long as the 
application warrants it. Of course, since the OP seems to be describing 
a graphical application, he may get a lot of mileage out of AJAX or 
something like it.

More information about the Mod_python mailing list