[cgiapp] CGI::Application & mod_perl 2

Jon Daily jonfdaily at gmail.com
Tue Nov 6 15:28:54 EST 2007


Hello,

I am porting a CGI::Application from CGI to mod_perl 2.

My first question is if there is a recommended resource for using
CGI::Application and mod_perl 2 together that I should use?

I did come across Michael Peters' CGI::Application::Plugin::Apache
module on CPAN.  I am attempting to use this to ease the transition,
however I am running into some issues when dealing with the session.

my httpd.conf looks like,

<Directory "/srv/www/myApp">
        SetHandler  perl-script
        PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        AllowOverride None
        Options FollowSymLinks +ExecCGI
        Order allow,deny
        Allow from all
</Directory>

my application code looks something like,

package myApp;
use base 'CGI::Application';
use CGI::Application::Plugin::Apache qw(:all);
use CGI::Application::Plugin::Session;

.....

sub cgiapp_init {
    my $self  = shift;
    my $query = $self->query;

    my $session = $self->session;
....
}

And when I try to access $self->session I get the following server error,

[error] Error executing class callback in init stage: Can't locate
auto/Apache2/Request/cookie.al in @INC (@INC contains:
/opt/appl/phase01 /usr/lib/perl5/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/5.8.8
/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .
/usr/local/apache2) at
/usr/lib/perl5/site_perl/5.8.8/CGI/Application/Plugin/Session.pm line
41\n

Here is the code from Application::Plugin::Session,
38:   # CGI::Session only works properly with CGI.pm so extract the
sid manually if
39:   # another module is being used
40:        if (Scalar::Util::blessed($params[1]) && ! $params[1]->isa('CGI')) {
41:            my $sid = $params[1]->cookie(CGI::Session->name) ||
$params[1]->param(CGI::Session->name);
42:            $params[1] = $sid;
43:        }

Should I be using Apache::Session instead?

Any help with this error, or general help for using sessions with
CGI::Application and mod_perl 2 is greatly appreciated,

Thanks,

- Jon


More information about the cgiapp mailing list