Hi all, I learned mod_perl / Mason the fun way: by just diving in to the baboon book, creating a site and making it up as I went along, using features as I learned of them. Of course that means that I've ended up with an unmaintainable, unscalable mess, but I've sure had fun! Anyway, I'm applying lessons learned and trying to clean things up, and I want to know how more experienced developers handle global configuration.
I have ended up with my custom site configuration information scattered around my code. Some of it is in a Mason-global hash called %siteconf, which is defined in a <%once> section in the top level autohandler. Some of it is defined with PerlSetVar in the httpd.conf file, accessed via $r->dir_config. Some of it is in various custom Perl modules. And of course some of it is hard-coded into code (gasp), although I've tried to avoid that for the most part. Obviously this is suboptimal. :-) My configuration information includes various pathnames, email addresses, numerical values, hostnames, etc. I'm trying to figure out what is the best way to consolidate them all so they are available to all code. I'm thinking about putting it all in a single hashref in a dedicated Perl module that could be accessed anywhere in the site, e.g. ----------------------------------------------------------------- package MySite::CustomConfig; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( $siteconf ); our $siteconf = { cfgvar1 => val1, ... }; 1; ---------------------------------------------------------------- I try to keep the site relocatable, so I use Apache2::ServerUtil::server_root() a lot to form the top parts of pathnames, but I wouldn't be able to get that from outside mod_perl, right? Maybe that's okay, since this is all meant to be used within the web code anyway, so this module would only be loaded within a mod_perl environment. Alternatively, I was thinking I could just try defining this hashref in a <Perl>...</Perl> section in httpd.conf. Any suggestions about a best practice for this? Regards, Charlie -- Charlie Katz Harvard-Smithsonian Center for Astrophysics [EMAIL PROTECTED] ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users