> For those of us less familiar with mod_perl, could someone
> explain a bit
> more why this is necessary and/or what the benefits are?

I'll try. I think Jesse means that in "pure mod_perl" that the "instance"
script is a registered Apache handler.

IMHO the traditional benefits of mod_perl are performance, and um... (Did I
mention performance?;-).

Also useful, albeit probably not on topic, a perl handler can actually
handle requests in almost any phase of the Apache request cycle. It could
authorize, authenticate, log, etc... Although I think cgiapp is mostly for
content handling.

Here's a short list of the various phases you can register under mod_perl1xx
discussed in more detail here:

http://perl.apache.org/docs/1.0/guide/config.html#Perl_Handlers

    PerlChildInitHandler
    PerlPostReadRequestHandler
    PerlInitHandler
   [...]
    PerlHandler
    PerlLogHandler
    PerlCleanupHandler
   [...]

Here is an example of a perl script being registered as a content handler in
httpd.conf:

# preload these modules
PerlModule Apache::DBI
PerlModule japhoo
<Location />
SetHandler perl-script
PerlHandler japhoo->handler
</Location>

Here is part of the perl to clarify what that does a bit:

package japhoo;
use Apache::Constants ':response'; #has DECLINED, OK for old mod_perl1.xx
use base qw/CGI::Application/; # this is what we are

sub setup {
          my $self = shift;
          $self->run_modes(
               'dd' => 'display_directory',
               'sd' => 'search_directory',
               'sl' => 'suggest_listing',
           );
           $self->start_mode('dd');
           $self->mode_param('rm');
}

sub handler ($$) {
        my ($pkg, $r) = @_;
        my $uri = $r->uri();

        unless ($uri eq '/') {
            return DECLINED if (-e $r->filename());
        }

        my $thing = $pkg->new(
                TMPL_PATH => $tpath,
                PARAMS => {
                        'REQ'  => $r,
                        'TMPL' => $tfile,
                }
        );
        $thing->run();
        return OK;
}

I would also mention 'PerlSetVar' in response to Jesse's previous question
about Apache admins inserting configurations.

You can also use 'PerlAddVar' to "push" values onto an array, and so by
extension if you are careful, you could construct a hash. (But that may be a
perl thing, beyond the average Apache driver like myself?<G>)

Here's the docs on that stuff:
http://perl.apache.org/docs/1.0/guide/config.html#PerlSetVar_and_PerlAddVar

HTH,
John


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to