perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip M. Gollucci" <pgollu...@p6m7g8.com>
Subject Re: Reading custom configuration parameters
Date Thu, 28 Sep 2006 22:28:49 GMT
Erik Norgaard wrote:
> Philip M. Gollucci wrote:
>> Erik Norgaard wrote:
>>> Hi:
>>>
>>> I have successfully created a module that declares some configuration 
>>> parameters which should be available to the handler: dbDriver, 
>>> dbHost, dbName, dbUser and dbPassword. Or so I think, I followed this 
>>> guide:
>>>
>>>   http://perl.apache.org/docs/2.0/user/config/custom.html
>> This section of it doesn't answer that for you ?
>> http://perl.apache.org/docs/2.0/user/config/custom.html#toc_Directive_Callback_Subroutine

>>
>>
>> The simple answer is try it :)
> 
> The yet simpler ? :) Well, what confuses me is the merging example in 
> the end of the text. Anyway, the text you refer to tells how I can get 
> global/serverwide parameters, but I don't see any mention of whether or 
> not parameters defined for a different virtual host is possible. I 
> prefer not for security.
I believe you can get to anything:

If a request is made to a resource inside a virtual host, $srv_cfg will contain the object
of the virtual host's server.
   my $srv_cfg = Apache2::Module::get_config('MyApache2::MyParameters', $s);

To reach the main server's configuration object use:
   use Apache2::Module ();
   use Apache2::ServerRec ();
   use Apache2::ServerUtil ();
   ...
   if ($s->is_virtual) {
       my $base_srv_cfg = Apache2::Module::get_config('MyApache2::MyParameters',
                                                     Apache2::ServerUtil->server);
       print $base_srv_cfg->{name};
   }

However, I think you can still get to anything you want:

   my $tree = Apache2::Directive::conftree();

by traversing this far enough down.  (see t/response/TestApache/conftree.pm)



-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

When I call your name, Girl, it starts to flame
Burning in my heart, Tearing it all apart..
No matter how I try My love I cannot hide....

Mime
View raw message