The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

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>'; }

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.

AUTHOR

Ryan Davis, Zen Spider Software <ryand-ch@zenspider.com>

PUBLIC METHODS

  • $ch = Apache::ContentHandler->new

      Creates a new ContentHandler. You should not override this, override
      _init instead.
  • $hc->run

    The main application structure. Provides for a standard header, body, and footer. You probably do not want to override this, override the individual methods instead.

PROTECTED METHODS

  • _init

    Private: called by new. Override to put your application specific variables here.

  • $val = $self->arg($key)

    Returns a CGI/mod_perl parameter for the key $key.

  • @keys = $self->args

    Returns a list of all of the mod_perl/cgi parameters.

  • $s = $hc->header

    Returns a string containing the preheader, an HTML title, and a postheader. You probably do not want to override this unless you want a different type of title.

  • $s = $hc->work

    Runs a method corresponding to the $action parameter, or the default action, and returns the content as the body of the document. If the $action does not exist, then it puts up a page stating that. This makes rapid prototyping very easy and quick.

  • $s = $hc->footer

    Returns a string containing the prefooter, and postfooter. This used to have a standard footer as well, but I found it annoying.

  • $s = $hc->errors

    Returns a dictionary list detailing the contents of the error hash, if any.

  • $s = $hc->preheader

    Returns the contents of the preheader. Override to add something before the title.

  • $s = $hc->postheader

    Returns the contents of the postheader. Override to add something after the title.

  • $s = $hc->prework

    Returns the contents of the prework. Override to add something before the body.

  • $s = $hc->postwork

    Returns the contents of the postwork. Override to add something after the body.

  • $s = $hc->prefooter

    Returns the contents of the prefooter. Override to add something before the footer.

  • $s = $hc->postfooter

    Returns the contents of the postfooter. Override to add something after the footer.

  • $s = $hc->reportError

    Sends an email to the addresses listed in error_email, detailing an error with as much debugging content as possible. Used for fatal conditions.

  • $s = $hc->dbi

    Returns a DBI connection. Override _init and add values for dbi_driver, dbi_user, and dbi_password to make this connection.

  • $s = $hc->sqlToTable

    Returns an HTML representation of a SQL statement in table form.

  • $s = $hc->sqlToArrays

    Returns an array representing a SQL query.

  • $s = $hc->sqlToHashes

    Returns a hash representing a SQL query.

  • $s = $hc->query1

    Returns a single value from a SQL query. The query must return a single column and row (ie SELECT name FROM users WHERE id=42).