You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Christopher H. Laco" <cl...@chrislaco.com> on 2005/09/02 05:08:17 UTC

dir_config

I'm trying to get at PerlSetVar configurations, and this doesn't work 
under MP2:


sub handler {
     my $r = shift;

     $r->print( $r->dir_config('MyConfig') );

     return Apache2::Const::OK;
};


I'm getting this in the logs:
> Can't locate object method "dir_config" via package "Apache2::RequestRec"


What am I missing here?
I haven't done any MP2 development thus far, and haven't done much mp1 
either. Just trying to toss together a wrapper around something quickly...

-=Chirs

Re: dir_config

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 2 Sep 2005, Christopher H. Laco wrote:

> Philip M. Gollucci wrote:
>> Christopher H. Laco wrote:
>> 
>>>> Can't locate object method "dir_config" via package "Apache2::RequestRec"
>> 
>> Thats a good question.  Your code looks fundamentally correct. Here's a 
>> live example maybe it will help.
>
> Here's what I've learned.
>
> handler {
> 	my $r = shift;
> };
>
> At this point, $r is a simple old RequestRec. IT appears I 
> have to use other mofules to enhance what $r can do.
>
> My problem was that I wasn't including RequestIO for print 
> or RequestUtil for dir_config.

For the archives, you can use ModPerl::MethodLookup to help
with errors like this:

bash$ perl -MModPerl::MethodLookup -e print_method dir_config
   There is more than one class with method 'dir_config'
   try one of:
 	use Apache2::RequestUtil ();
 	use Apache2::ServerUtil ();
-- 
best regards,
randy kobes


Re: dir_config

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Christopher H. Laco wrote:
> At this point, $r is a simple old RequestRec. IT appears I have to  use 
> other mofules to enhance what $r can do.
> 
> My problem was that I wasn't including RequestIO for print or 
> RequestUtil for dir_config.

Me thinks you want to put stuff in your startup.pl file

See:
http://perl.apache.org/docs/2.0/user/handlers/server.html#Startup_File


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Re: dir_config

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Philip M. Gollucci wrote:
> Christopher H. Laco wrote:
> 
>>> Can't locate object method "dir_config" via package 
>>> "Apache2::RequestRec"
> 
> Thats a good question.  Your code looks fundamentally correct. Here's a 
> live example maybe it will help.

Here's what I've learned.

handler {
	my $r = shift;
};

At this point, $r is a simple old RequestRec. IT appears I have to  use 
other mofules to enhance what $r can do.

My problem was that I wasn't including RequestIO for print or 
RequestUtil for dir_config.


-=CHris

Re: dir_config

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Christopher H. Laco wrote:
>> Can't locate object method "dir_config" via package "Apache2::RequestRec"
Thats a good question.  Your code looks fundamentally correct. Here's a live 
example maybe it will help.

http://p6m7g8.net/dir_config

<Location /dir_config>
     SetHandler modperl
     PerlResponseHandler TEST::DirConfig
     PerlSetVar Config test
</Location>

package TEST::DirConfig;

use strict;
use warnings FATAL => 'all';
use Carp;

use Apache2::RequestRec ();
use Apache2::Const -compile => qw(OK);

sub handler {

     my $r = shift;

     $r->print($r->dir_config('Config'));
     return Apache2::Const::OK;
}

1;



-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Re: dir_config

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Christopher H. Laco wrote:
> While I'm at it...what's the Apache2:: equivilent of SCRIPT_NAME?

$r->uri

See: http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_uri_

In the future, try to post new questions as a separate email, not as a reply
to an existing thread. Makes it harder to identify what the e-mail is about.

-- 
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: dir_config

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
While I'm at it...what's the Apache2:: equivilent of SCRIPT_NAME?

-=Chris