package CGI::Application::Loop; use base qw[ CGI::Application ]; 1; package main; unless( caller() ) { use Devel::TraceCalls { Package => "CGI::Application" }; my $app = CGI::Application::Loop->new(); print STDERR "\nTRACE: CONSTRUCTED**(\n"; $app->run; print STDERR "\nTRACE: RUNNED**(\n"; $app->run; } __END__ perl cgi.application.loop.pl >NUL 2>twoy perl -lne" print qq[=head3 $1\n\n] if m{^TRACE:[^\w]+(.*?)\(} " twoy >>cgi.application.loop.pl =head1 What is the application loop? Well, first you create an object of your CGI::Application subclass (or CGI::Application). You use L>|/CGI::Application::new> for this. After you have created an instance of your application ( Cnew> ), you run it (Lrun>|/CGI::Application::run>), and that's it (L>|/CGI::Application::run> has a loop of its own). At that point your CGI::Application object should go out of scope (or be undef'ed) and subsequently be DESTROY'ed. =head2 CGI::Application::new The constructor. It sets defaults for the following: =over 4 =item * C<$self-Eheader_type> =item * C<$self-Emode_param> =item * C<$self-Estart_mode> =back It then calls Lcgiapp_init>|"CGI::Application::cgiapp_init">, and Lsetup>|"CGI::Application::setup">. =head3 CGI::Application::cgiapp_init This one I must provide. It's a good place to initialize a database handle. =head3 CGI::Application::setup This one also I must provide, and it should set C<$self-Estart_mode>, and C<$self-Erun_modes> =head2 CGI::Application::run The C method is the I of CGI::Application. It fetches the L object. It fetches the mode_param, and the current mode, and if there is no current run mode specified, it fetches the start_mode. It then invokes L. It then invokes the actual run mode (whatever it may be, start_mode or otherwise). It then I the headers using C and C. It then sends "I". And it finally calls Lteardown()>|/CGI::Application::teardown>. =head3 CGI::Application::query Returns the query object ;)( usually a C object, but you can just as easily use a completely B C object). If one doesn't exist, one will be created using C<$self-Ecgiapp_get_query>. Creates a CGI.pm object on the fly. #=head3 CGI::Application::mode_param #=head3 CGI::Application::start_mode =head3 CGI::Application::cgiapp_prerun This one you must provide. It is a good place to fetch a user object from someplace. =head3 CGI::Application::teardown This is a good place to destroy your database handle, unless you're running in a persistent environment (aka unless C<$ENV{MOD_PERL}>). Since it is invoked upon each I>, it is a good place to delete I objects and such. =cut