Apache-ContentHandler

 view release on metacpan or  search on metacpan

ContentHandler.pm  view on Meta::CPAN

package Apache::ContentHandler;

=head1 NAME

Apache::ContentHandler - mod_perl extension for uniform application
generation.

=head1 SYNOPSIS

    use Apache::ContentHandler;

    @ISA = 'Apache::ContentHandler';

    sub handler {
      my $r = shift;
      my $algometer = new Apache::Algometer($r);
      my $result = $algometer->run;
      return $result;
    }

    sub _init {
      my $self = shift || die 'need $self';
      $self->SUPER::_init(@_);

      # overrides
      $self->{title}     = 'Project Algometer';
      $self->{subtitle}  = "Version $VERSION";
      $self->{default_action} = 'hello';
      # other variable definitions
    }

    sub hello {
      return '<P>Hello World</P>';
    }

=head1 DESCRIPTION

Apache::ContentHandler is a generic framework for creating mod_perl
based applications. It provides a basic event mechanism and a
subclassable framework for customizing actions.

The synopsis shows a very simple example of what it can do. In this
case, we set the default_action to 'hello', which is automatically
executed. Hello in this case outputs a simple paragraph. Nothing big,
but it is very simple. Note that this app runs as-is in both CGI and
mod_perl.

=head2 Rapid Prototyping

This does not demonstrate the real power of ContentHandler. The real
power comes from rapid prototyping. For example, if we modifed the
example above to read:

    sub hello {
      my $self = shift || die 'need $self';
      my $s = '';
      $s .= '\<A HREF="$self-\>{url}?action=make"\>Make\</A\> something.';
      return $s;
    }

Then the page will output a url for the application that includes
"action=make" as a url parameter. This will tell ContentHandler to run
the method make when executed. But, 'make' does not exist at this
time. That is ok, because ContentHandler will deal with it by putting
a standard page up explaining that that feature is not yet
implemented. This allows you to quickly prototype one page, and move
on to the rest of the functionality one piece at a time.

I have used this style with clients on several different projects and
they were all extremely happy to get something tangible in a very
short period of time, usually 5 minutes to get the first page up and
running with skeletal functionality. From there, it is a very
interactive process with the client driving on one machine and
commenting, and me coding away at another machine as they talk.

=head1 PUBLIC METHODS

=over 4

=cut

use strict;
use vars qw($VERSION);



( run in 1.541 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )