You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jonathan Vanasco <jv...@2xlp.com> on 2007/05/03 02:20:22 UTC
location
I'm cleaning up some code for a dispatch class I wrote, and got very
confused:
I found that i was accessing location from $r ( ApacheRequestReq
Object )
location isn't a documented function of $r though. why is that
working for me ?
Re: location
Posted by Jonathan Vanasco <jv...@2xlp.com>.
On May 3, 2007, at 12:43 PM, Torsten Foertsch wrote:
> Note that all these functions are methods of the $r object.
oh!
ok, now i see. that makes total sense. i thought i had to access
these methods via their own packages, not that they were exported
into the ApacheRequestRec class.
Re: location
Posted by Torsten Foertsch <to...@gmx.net>.
On Thursday 03 May 2007 18:09, Jonathan Vanasco wrote:
> On May 3, 2007, at 10:54 AM, Torsten Foertsch wrote:
> > You see the location function is created directly in the
> > Apache2::RequestRec
> > namespace (the PACKAGE = ...).
> >
> > The perl equivalent would be a file named Apache2/RequestUtil.pm
> > that starts
> > with a "package Apache2::RequestRec" line. When you now load
> > Apache2::RequestUtil all functions in the file will be added to the
> > Apache2::RequestRec namespace.
> >
> > This is a common pattern in mod_perl.
>
> So then this is a documentation bug of sorts ?
>
> It seems like a gray area -- I can change my code to use RequestUtil
> if needed, I just don't want anything that isn't written to spec.
It's quite simple. You start with
use Apache2::RequestRec;
then you'll have $r->prev, $r->main, $r->notes, $r->args etc. Once you need
location() or pnotes() or is_initial_req() you pull in
use Apache2::RequestUtil;
For output you'll propably want to $r->print(...). Now you also need
use Apache2::RequestIO;
To use internal_redirect(), lookup_uri() etc you'll need also
use Apache2::SubRequest;
Note that all these functions are methods of the $r object.
If you don't know what module you need for what method try
perl -MModPerl::MethodLookup -e print_method METHODNAME
For example
$ perl -MModPerl::MethodLookup -e print_method location
To use method 'location' add:
use Apache2::RequestUtil ();
Torsten
RE: location
Posted by Adam Prime x443 <ap...@brunico.com>.
You're probably using Apache2::RequestUtil in startup.pl, or some other
file you're also use'ing prior if you aren't getting an error already
when you try to call $r->location.
Adam
-----Original Message-----
From: Jonathan Vanasco [mailto:jvanasco@2xlp.com]
Sent: Thursday, May 03, 2007 12:10 PM
To: Torsten Foertsch
Cc: modperl@perl.apache.org
Subject: Re: location
On May 3, 2007, at 10:54 AM, Torsten Foertsch wrote:
> You see the location function is created directly in the
> Apache2::RequestRec
> namespace (the PACKAGE = ...).
>
> The perl equivalent would be a file named Apache2/RequestUtil.pm
> that starts
> with a "package Apache2::RequestRec" line. When you now load
> Apache2::RequestUtil all functions in the file will be added to the
> Apache2::RequestRec namespace.
>
> This is a common pattern in mod_perl.
So then this is a documentation bug of sorts ?
It seems like a gray area -- I can change my code to use RequestUtil
if needed, I just don't want anything that isn't written to spec.
Re: location
Posted by Jonathan Vanasco <jv...@2xlp.com>.
On May 3, 2007, at 10:54 AM, Torsten Foertsch wrote:
> You see the location function is created directly in the
> Apache2::RequestRec
> namespace (the PACKAGE = ...).
>
> The perl equivalent would be a file named Apache2/RequestUtil.pm
> that starts
> with a "package Apache2::RequestRec" line. When you now load
> Apache2::RequestUtil all functions in the file will be added to the
> Apache2::RequestRec namespace.
>
> This is a common pattern in mod_perl.
So then this is a documentation bug of sorts ?
It seems like a gray area -- I can change my code to use RequestUtil
if needed, I just don't want anything that isn't written to spec.
Re: location
Posted by Torsten Foertsch <to...@gmx.net>.
On Thursday 03 May 2007 16:34, Jonathan Vanasco wrote:
> On May 3, 2007, at 2:54 AM, Torsten Foertsch wrote:
> > http://perl.apache.org/docs/2.0/api/Apache2/
> > RequestUtil.html#C_location_
>
> Thats even odder...
>
> $r is a RequestRec, not RequestUtil
>
> And according to those docs, RequestUtil ISA RequestRec , not the
> other way around.
>
> location really shouldn't be working out of RequestRec then.
This is an excerpt from the generated
WrapXS/Apache2/RequestUtil/RequestUtil.xs
MODULE = Apache2::RequestUtil PACKAGE = Apache2::RequestRec PREFIX =
mpxs_Apache2__RequestRec_
char *
mpxs_Apache2__RequestRec_location(r)
Apache2::RequestRec r
You see the location function is created directly in the Apache2::RequestRec
namespace (the PACKAGE = ...).
The perl equivalent would be a file named Apache2/RequestUtil.pm that starts
with a "package Apache2::RequestRec" line. When you now load
Apache2::RequestUtil all functions in the file will be added to the
Apache2::RequestRec namespace.
This is a common pattern in mod_perl.
Torsten
Re: location
Posted by Jonathan Vanasco <jv...@2xlp.com>.
On May 3, 2007, at 2:54 AM, Torsten Foertsch wrote:
> http://perl.apache.org/docs/2.0/api/Apache2/
> RequestUtil.html#C_location_
Thats even odder...
$r is a RequestRec, not RequestUtil
And according to those docs, RequestUtil ISA RequestRec , not the
other way around.
location really shouldn't be working out of RequestRec then.
Re: location
Posted by Torsten Foertsch <to...@gmx.net>.
On Thursday 03 May 2007 02:20, Jonathan Vanasco wrote:
> I'm cleaning up some code for a dispatch class I wrote, and got very
> confused:
>
> I found that i was accessing location from $r ( ApacheRequestReq
> Object )
>
> location isn't a documented function of $r though. why is that
> working for me ?
http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_location_
Torsten