finding "context" in mod_perl handler

finding "context" in mod_perl handler

am 21.04.2009 12:16:07 von aw

Hi.

Supposing I have this kind of setup


PerlAuthenhandler My::AuthModule
...


....


PerlAuthenhandler My::AuthModule
...


and a request is made for "/xyz", and as a result the module is called,

is there some way in My::AuthModule::handler(), by which I can find out
that, in *this* instance, I am being called in the "context" of the
directive above, as opposed to the case ?

I mean, I could do something like respectively
PerlSetVar context "location:/xyz"
and
PerlSetVar context "dir:/some/path"

and then check the var in the handler, but there has to be a
better/cleaner way, no ?

Thanks
André

Re: finding "context" in mod_perl handler

am 21.04.2009 16:57:19 von Adam Prime

André Warnier wrote:
> Hi.
>
> Supposing I have this kind of setup
>
>
> PerlAuthenhandler My::AuthModule
> ...
>

>
> ...
>
>
> PerlAuthenhandler My::AuthModule
> ...
>

>
> and a request is made for "/xyz", and as a result the module is called,
>
> is there some way in My::AuthModule::handler(), by which I can find out
> that, in *this* instance, I am being called in the "context" of the
> directive above, as opposed to the case ?
>
> I mean, I could do something like respectively
> PerlSetVar context "location:/xyz"
> and
> PerlSetVar context "dir:/some/path"
>
> and then check the var in the handler, but there has to be a
> better/cleaner way, no ?

The first thing i'd try is checking $r->location. I'm not sure what
that does for the Directory instance, but in the Location instance it'll
return '/xyz'. I don't know of a comparable way to do the same thing
with Directory directives.

Adam

Re: finding "context" in mod_perl handler

am 21.04.2009 19:47:45 von Perrin Harkins

On Tue, Apr 21, 2009 at 6:16 AM, Andr=E9 Warnier wrote:
> I mean, I could do something like respectively
> =A0PerlSetVar context "location:/xyz"
> and
> =A0PerlSetVar context "dir:/some/path"
>
> and then check the var in the handler, but there has to be a better/clean=
er
> way, no ?

That's what I would do. Easy and foolproof.

- Perrin

Re: finding "context" in mod_perl handler

am 21.04.2009 19:49:42 von Perrin Harkins

On Tue, Apr 21, 2009 at 1:47 PM, Perrin Harkins wrote:
> On Tue, Apr 21, 2009 at 6:16 AM, Andr=E9 Warnier wrote:
>> I mean, I could do something like respectively
>> =A0PerlSetVar context "location:/xyz"
>> and
>> =A0PerlSetVar context "dir:/some/path"
>>
>> and then check the var in the handler, but there has to be a better/clea=
ner
>> way, no ?
>
> That's what I would do. =A0Easy and foolproof.

Assuming of course that you care about Directory xyz vs Location xyz.
If they're totally different URLs, then checking the location is all
you need.

- Perrin

Re: finding "context" in mod_perl handler

am 21.04.2009 19:52:25 von David Ihnen

André Warnier wrote:
> Hi.
>
> Supposing I have this kind of setup
>
> and then check the var in the handler, but there has to be a
> better/cleaner way, no ?
>
> Thanks
> André
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html# C_path_info_

Just get the info from the request object within the handler?

David