You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Doug MacEachern <do...@pobox.com> on 2000/02/17 01:08:08 UTC

Re: perlhandler -> CGI.pm -> no request object?

On Mon, 31 Jan 2000, Brian Reichert wrote:

> On Fri, Jan 28, 2000 at 06:46:27PM -0500, Brian Reichert wrote:
> > Sorry about the confusing subject line.
> > 
> > I'm witnessing a symptom:
> > 
> > Using apache_1.3.9 and mod_perl-1.21 and CGI.pm-2.56 under 3.2-STABLE.
> 
> I have an update:  under the above software versions, when I
> tightened my handler to this:
> 
> -----
> 
> sub handler
> {
>   my $r = shift;

add this:

    Apache->request($r);
 
>   print STDERR "handler SetLogin: here we go...\n";
>   
>   print STDERR "uri is ".$r->uri."\n";
>   
>   $r = Apache->request;
>   
>   print STDERR "uri is now ".$r->uri."\n";
> 
>   return OK;
> }
> 
> -----
> 
> I get the following in my error logs:
> 
>   uri is /members/announce.html
> 
>   [Mon Jan 31 11:55:57 2000] [error] Can't call method "uri" on an
>   undefined value at
>   /home/reichert/build/under_CVS/website/lib/perl/Apache/SetLogin.pm
>   line 30.
> 
> It would seem that I cannot have two references to the request
> object.  of course, the Apache module has already handed me one in
> @_.  It this a bug in mod_perl?  This behavior certainly isn't
> documented...

it is documented:
=item Apache->request([$r])

The Apache->request method will return a reference to the request object.

B<Perl*Handler>s can obtain a reference to the request object when it
is passed to them via C<@_>.  However, scripts that run under 
B<Apache::Registry>, for example, need a way to access the request object.
B<Apache::Registry> will make a request object available to these scripts
by passing an object reference to C<Apache-E<gt>request($r)>.
If handlers use modules such as B<CGI::Apache> that need to access
C<Apache-E<gt>request>, they too should do this (e.g. B<Apache::Status>).

---

granted, it's not that clear.  you need to set the Apache->request
yourself if your Perl*Handler is using something that needs it, e.g.
CGI.pm