You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Steve Duran <st...@nmmcc.com> on 2005/08/11 03:54:59 UTC
[MP2] having trouble obtaining $r
Sorry, my last email was sent out without a subject.
I'm having trouble getting the request object from mod_perl. Here is the original attempt:
#use Apache2::RequestUtil;
use Apache2::compat;
use Apache;
my $r = Apache->request();
This generates the following error:
Bareword "Apache2::ServerUtil::server_root" not allowed while "strict subs" in use at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Apache2/compat.pm line 346.
BEGIN not safe after errors--compilation aborted at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Apache2/compat.pm line 429.
-----------------------------------------------------------------------------------------------
This is the second attempt:
use Apache2::RequestUtil;
#use Apache2::compat;
#use Apache;
my $r = Apache2::RequestUtil->request;
This produces the following error:
Can't locate object method "request" via package "Apache2::RequestUtil"
-----------------------------------------------------------------------------------------------
This is the corresponding section of the httpd.conf file. Uncommenting the SetHandler directive causes the browser to display the code of the perl script.
LoadModule perl_module modules/mod_perl.so
PerlModule Apache2::compat
AddHandler cgi-script .cgi
AddHandler perl-script .pl
Alias /auth/ "/web/ssldocs/foobar/auth/"
<Directory /web/ssldocs/foobar/auth>
AllowOverride None
Options +ExecCGI
#SetHandler perl-script
PerlOptions +GlobalRequest
</Directory>
Please advise.
Thanks,
Steve
Re: [MP2] having trouble obtaining $r
Posted by Arne Skjaerholt <ar...@broadpark.no>.
Have you tried to put use Apache2::RequestReq; along with the other use
statements? I ran into the same problem, except that I wanted
Apache2::ServerUtil->server, and that was fixed by including
Apache2::ServerRec as well as Apache2::ServerUtil. I'm not entirely sure
why this is, but it's probably related to the fact that
Apache2::[Server,Request]Util extendthe functionality of the
ServerRec/RequestRec classes.
Hopefully this'll fix it.
Arne
:wq
>
Re: [MP2] having trouble obtaining $r
Posted by Stas Bekman <st...@stason.org>.
> use Apache2::RequestUtil;
> my $r = Apache2::RequestUtil->request;
>
> This produces the following error:
>
> Can't locate object method "request" via package "Apache2::RequestUtil"
[...]
> LoadModule perl_module modules/mod_perl.so
>
> PerlModule Apache2::compat
>
> AddHandler cgi-script .cgi
> AddHandler perl-script .pl
>
> Alias /auth/ "/web/ssldocs/foobar/auth/"
>
> <Directory /web/ssldocs/foobar/auth>
> AllowOverride None
> Options +ExecCGI
> #SetHandler perl-script
> PerlOptions +GlobalRequest
> </Directory>
and where exactly do you configure, the registry module, Steve? I can't
see it in this config.
What if you chance that config to:
<Directory /web/ssldocs/foobar/auth>
AllowOverride None
Options +ExecCGI
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
</Directory>
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [MP2] having trouble obtaining $r
Posted by Carl Johnstone <mo...@fadetoblack.demon.co.uk>.
Message>>>>>
I'm having trouble getting the request object from mod_perl. Here is the
original attempt:
<<<<<
Have you simply tried:
my $r = shift;
at the beginning of your handler? If you're using Apache::Registry, then
your whole file is a handler so you can do that at the top.
Carl