Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Apache::Request::Dispatcher 0.2.1

    Download button

    No screenshots available
    Downloads: 413  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Bradley Kite | More programs
    Perl Artistic License / FREE
    October 7th, 2010, 08:57 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Apache::Request::Dispatcher description

    A Perl module which dispatches requests to a sub-class of Apache::Request::Controller.

    Apache::Request::Dispatcher Perl module dispatches requests to a sub-class of Apache::Request::Controller.

    SYNOPSIS

    < Location /myApplication >
    SetHandler perl-script
    Perlhander Apache::Request::Dispatcher
    SetEnv DispatcherConf /path/to/file.cfg
    setEnv APP_NAME myApplication
    < /Location >


    Apache::Request::Dispatcher is a mod_perl handler which handles Apache HTTP requests under mod_perl, and dispatches them to a sub-class of Apache::Request::Controller (after some initial request setup has been performed).

    If required, it will establish a connection to a database using the DBI, retrieve (or create) session data for this request (using Apache::Session), initialise a template processor (using the Template-Toolkit).

    The Dispatcher parses the URI of the request to determine which subclass of Apache::Request::Controller to then pass control to.

    Parsing of the URI occurs as follows:

    APP_NAME (environment set in Apache Config) is removed from the begining of the URI, so that:

    '/myApplication/SubClass/action'
    becomes: 'SubClass/action'
    or
    '/myApplication/Sub/Class/action'
    becomes: 'Sub/Class/action'

    This is then converted to a module name, and a method name, such as:

    Apache::Request::Controller::SubClass or
    Apache::Request::Controller::Sub::Class

    with action() being the method name.

    It should be noted that if the SubClass or Action name contain any thing other than [A-Za-z0-9_] then the request is declined.

    The dispatcher then dynamically inherits from the module name, and then calls $self->action().

    The action() method of the controller is then called in an object-oriented fashion, with a dispatcher object passed in as its first parameter.

    This object contains the following hash elements:

    request => $r, # The Apache Request Object
    dbh => $dbh, # The Database Connection Object
    cfg => $cfg, # The AppConfig object
    template => $template, # The Template Processor
    apr => $q, # The CGI/libapreq object
    session => %session # Any session data for this user


    Depending on the configuration file, 'dbh' or 'session' may be undefined if they've been turned off.

    an example controller method might be written as follows:

    package Apache::Request::Controller::SubClass;
    our @ISA = qw(Apache::Request::Controller);
    use strict;
    use Apache::Const qw(:common :methods :http);


    sub action
    {
    my $self = shift;

    my $thing = getThingByID($self->{'dbh'}, $self->{'apr'}->param('thingId'));

    $self->{'request'}->status(HTTP_OK);
    $self->{'request'}->content_type('text/html');

    $self->{'template'}->process('myTemplate', {thing => $thing});
    return OK;
    }
    1;


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    dispatch requests | Apache::Request::Controller sub-class | Perl module | Apache | requests | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM