in reply to Advice on storage of Apache app configuration information?
You could also use mod_perl directives and stick it right in your apache config file. Many mason apps already have a fair amount of stuff in the apache config file.
Try something like:
<Perl> Package MyAppConfig; my $cfg = { DBMpath => '/foo/bar/quux', salt => 'NaCl', baseDir => '/baz/bar/foo', }; sub salt { my ($class,$salt) = @_; $cfg->{salt} = $salt if $salt; return $cfg->{salt}; } # Write accessors/mutators as desired for the other elements too. </Perl>
You should be able to access the config from your Mason app. The accessor/mutators aren't realy necessary, they just make accessing data a bit cleaner. If you write accessors, consider putting them in an actual separate module file. Then put only the $cfg variable in your apache config (or go all out and set the values with mutator sub calls).
or you could even use plain apache configuration:<Perl> MyAppConfig->salt('NaCl'); MyAppConfig->DBMpath('/foo/bar/gack'); </Perl>
Access these with:PerlAddVar MySalt NaCl PerlAddVar MyDBMPath /foo/bar/yak PerlAddVar MyBaseDir /bar/foo/mkay
my $salt = $r->dir_config->get('MySalt');
What is best really depends on your needs. It may not even make sense for you to put the configuration in your apache configuration.
Good luck.
TGI says moo
|
|---|