You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Adam Prime x443 <ap...@brunico.com> on 2005/05/25 18:53:05 UTC

$r->location() question

Assume i have a handler that sits in a location, and that handler has it's own admin interface built in.  I also want to be able to easily change the directory that the handler is running in, or have it running in multiple locations (so i don't want to hardcode the location into the script. 

So my .conf looks like this.

    <Location /crap>
        SetHandler perl-script
        PerlHandler Something::Crap 
    </Location>

    <Location /crap/admin>
        AuthName "Something"
        AuthType Crap

        PerlAuthenHandler Something::Authen
        PerlAuthzHandler Something::Authz
        require valid-user
    </Location>

The only annoying thing about this is that $r->location will return '/crap/admin/' when i'm on the admin part of the site.  Is there any way to get the actual location that the PerlHandler is running in despite the fact i'm using Authen and Authz handlers in /crap/admin/?

Right now i just parse the /admin out of the location() myself, but that's kind of annoying.  I haven't tried resetting the location though (like $r->location($newlocation)) but i'm not sure if that will work offhand.

Is there a better way to do this kind of thing?

Adam

Re: $r->location() question

Posted by Stas Bekman <st...@stason.org>.
Adam Prime x443 wrote:
> Assume i have a handler that sits in a location, and that handler has
> it's own admin interface built in.  I also want to be able to easily
> change the directory that the handler is running in, or have it running
> in multiple locations (so i don't want to hardcode the location into
> the script.
> 
> So my .conf looks like this.
> 
> <Location /crap> SetHandler perl-script PerlHandler Something::Crap 
> </Location>
> 
> <Location /crap/admin> AuthName "Something" AuthType Crap
> 
> PerlAuthenHandler Something::Authen PerlAuthzHandler Something::Authz 
> require valid-user </Location>
> 
> The only annoying thing about this is that $r->location will return
> '/crap/admin/' when i'm on the admin part of the site.  Is there any
> way to get the actual location that the PerlHandler is running in
> despite the fact i'm using Authen and Authz handlers in /crap/admin/?

/crap/admin/ *is* the actual location.

> Right now i just parse the /admin out of the location() myself, but
> that's kind of annoying.  I haven't tried resetting the location though
> (like $r->location($newlocation)) but i'm not sure if that will work
> offhand.
> 
> Is there a better way to do this kind of thing?

sure: write a fixup handler which will set $r->location to whatever you want:
http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlFixupHandler


-- 
__________________________________________________________________
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