[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] cgiapp_init and cgiapp_prerun


> I am right in assuming that cgiapp_init, is call when the cgi application is
> first loaded and will only run once, no matter how many run modes are called
> with the application.

Yes, so long as you understand that "the application" exists as one
process of input.  e.g. if a user loads a "View" page, then chooses one
widget to "Edit", then submits said edits (which puts in the edits and
returns the Edit output again), you've had 3 runs of the application,
and 3 cgiapp_init calls.  The last instance may have hit multiple
run_modes (i.e. the "Submit_Edit" runmode saved the changes, then called
the "Edit" runmode to display the widget once more).

HTTP is stateless, and CGI::App doesn't change that, it just makes it
easy to process a request for a given state.

> I.e. if I had a form in one run mode which then passed the results into a
> runmode within the existing from, cgiapp_init would not rerun.

I think this is false.  Every time info comes into the app, cgiapp_init
is called.  It has no knowledge of whether a user has ever been to a
given run_mode, it only has the knowledge the user sends, and whatever
server side info your provide.

> And am I also right in assuming that cgiapp_prerun will run before any run
> mode is executed, so that it would be a perfect place to put in session
> validation..

The general process flow EVERYTIME THE USER SENDS DATA is:

new()
cgiapp_init()
setup()
cgiapp_prerun()
(whatever run mode is called.  This might in turn call other runmodes,
but cgiapp_prerun() is not called again).

However, session validation is one of the listed reasons for
cgiapp_prerun, so your idea there is correct.

I hope that explains things better.
-- 
SwiftOne  /  Brett Sanger
suppressed   

---------------------------------------------------------------------
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.