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).

<Perl> MyAppConfig->salt('NaCl'); MyAppConfig->DBMpath('/foo/bar/gack'); </Perl>
or you could even use plain apache configuration:
PerlAddVar MySalt NaCl PerlAddVar MyDBMPath /foo/bar/yak PerlAddVar MyBaseDir /bar/foo/mkay
Access these with:
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


In reply to Re: Advice on storage of Apache app configuration information? by TGI
in thread Advice on storage of Apache app configuration information? by William G. Davis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.