CGI-Snapp-Demo-Four
view release on metacpan or search on metacpan
lib/CGI/Snapp/Demo/Four.pm view on Meta::CPAN
$self -> param(run_mode_visited => []);
$self -> param(non_mode_visited => []);
$self -> start_mode('first_rm');
$self -> run_modes(first_rm => 'first_rm_method', second_rm => 'second_rm_method', third_rm => 'third_rm_method');
} # End of setup.
# ------------------------------------------------
sub third_rm_method
{
my($self) = @_;
my($ara) = $self -> param('run_mode_visited');
$self -> log(debug => 'third_rm_method()');
push @$ara, 'third_rm_method()';
$self -> param(run_mode_visited => $ara);
return $self -> build_head . $self -> build_form($self -> get_current_runmode, 'first_rm') . $self -> build_visits . $self -> build_tail;
} # End of third_rm_method.
# ------------------------------------------------
1;
=pod
=head1 NAME
CGI::Snapp::Demo::Four - A template-free demo of CGI::Snapp using Log::Handler::Plugin::DBI
=head1 Synopsis
After installing the module (see L</Installation>), do one or both of:
=over 4
=item o Use the L<CGI> script
Unpack the distro and copy http/cgi-bin/cgi.snapp.four.cgi to your web server's cgi-bin/ directory, and make it executable.
Then browse to http://127.0.0.1/cgi-bin/cgi.snapp.four.cgi.
=item o Use the L<PSGI> script
Note: In order to not require users to install L<Starman> or L<Plack>, they have been commented out in Build.PL and Makefile.PL.
Edit httpd/cgi-bin/cgi.snapp.four.psgi and change my value for the web server's doc root from /dev/shm/html to match your set up.
/dev/shm/ is a directory provided by L<Debian|http://www.debian.org/> which is actually a RAM disk, and within that my doc root is the sub-directory /dev/shm/html/.
Then, install L<Plack> and L<Starman> and then do one or both of:
=over 4
=item o Use L<Starman>
Start starman with: starman -l 127.0.0.1:5174 --workers 1 httpd/cgi-bin/cgi.snapp.four.psgi &
=item o Use L<Plack>
Start plackup with: plackup -l 127.0.0.1:5174 httpd/cgi-bin/cgi.snapp.four.psgi &
=back
Then, with either starman or plackup, direct your browser to hit 127.0.0.1:5174/.
These commands are copied from comments within httpd/cgi-bin/cgi.snapp.four.psgi. The value 5174 is of course just a suggestion. All demos in this series use port 5171 and up.
=back
=head1 Description
This is a version of L<CGI::Snapp::Demo::Two> which shows how to use a plugin such as L<Log::Handler::Plugin::DBI> within a CGI script based on L<CGI::Snapp>.
The output reports which methods were and were not entered per run mode.
Using a plugin easily requires a wrapper class, which here is L<CGI::Snapp::Demo::Four::Wrapper>. That's why httpd/cgi-bin/cgi.snapp.demo.four.cgi uses the wrapper instead
of using this module directly.
=head1 Distributions
This module is available as a Unix-style distro (*.tgz).
See L<http://savage.net.au/Perl-modules/html/installing-a-module.html>
for help on unpacking and installing distros.
=head1 Installation
=head2 Installing the module
Install L<CGI::Snapp::Demo::Four> as you would for any C<Perl> module:
Run:
cpanm CGI::Snapp::Demo::Four
or run:
sudo cpan CGI::Snapp::Demo::Four
or unpack the distro, and then either:
perl Build.PL
./Build
./Build test
sudo ./Build install
or:
perl Makefile.PL
make (or dmake or nmake)
make test
make install
=head2 Configuring the L<CGI> script's source code and the logger's config file
You I<must> edit both the source code of httpd/cgi-bin/cgi.snapp.demo.four.cgi and the config (text) file, to make this demo work.
Details:
=over 4
=item o The L<CGI> script's source code
In cgi.snapp.demo.four.cgi you'll see this code (which is my default set up, /dev/shm/ being Debian's RAM disk):
( run in 1.040 second using v1.01-cache-2.11-cpan-e93a5daba3e )