On Jan 7, 2005, at 12:59 PM, Michael Graham wrote:
I am using CGI::App in a mod_perl environment. I typically have run_modes submit back to themselves for validation, etc. If the form information "passes", I return $self->next_run_mode (just an example). I have made a couple of changes to my previous coding style. First, I am using path_info to get the runmode (makes linking and handlerdispatching much simpler). Second, because of the first, I want to useredirects to move from one run_mode to the next; that is, a form submits back to itself and is validated, I do a $self->redirect('next_run_mode'). It seems that redirects do not conserve the POST information. Is this true? If so, does this sound familiar to others? What other coding idioms do people use besides submit-to-self?I think the "submit-to-self, then redirect" method is the cleanest. Notalways the best performing (because you have two HTTP requests after a successful submit), but this method creates the fewest problems for browsers and for your application.
I do like the submit to self because all my code for validation, state changes, etc., is then relatively self-contained. At this point, almost all my databases are read-only (with the exception of user-management), so I'm not too worried about the double submit issue for that type of data (which I can catch with a simple uniqueness check).
So because of this, I'm trying to follow this rule of thumb: use POST for submitting data that changes the state of the application and GET for requesting pages without changing the app's state. That's more or less what the HTTP spec tells you to do anyway, AFAIR. As I understand it, your main problem with this approach is that "redirects do not conserve the POST information". Which POST information are you trying to conserve? You can add query params to the redirect URL, so you can pass a small amount of state information that way.
Adding the information as a GET is something that I could certainly do. As an example, I have a form that allows users to do a query (give the parameter for a SQL statement). The display on the next page can be configured via multiple parameters (about 8, a couple that allow multiple values). It is this information that I would like to hang onto. One possibility is to store these parameters in a session, but if the user does a back a few times and resubmits a page that has session information from a later page, the results might be unexpected. I could stuff all of this into a GET (I'm fairly sure the resulting string wouldn't be too long?), and perhaps that is what I should do for the redirect.
For an example, I wrote a quick database for gene expression profiles. We have a quirky access for it (you apply to via email submission rather than automatic), but it is available. As you can see from the URL, it is not mod_perl based and has somewhat limited functionality compared to what I am currently trying to develop.
http://ntddb.abcc.ncifrcf.gov/cgi-bin/nltissue.pl
Thanks for all the insight from the group....
Sean
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.