Nathanial P. Hendler wrote:
Ok, so I'm convinced that I should be using Log::Log4Perl.  I'm using
ModPerl::Registry and was wondering if people could share their approaches
to configuration variables and database handlers under mp2.

I'd like to have a config module, that holds things like:

  $document_root    = '/var/www/html';
  $images_base_path = $document_root . '/images';
  $images_base_url  = '/images';

  %phrases = ( red=>'This is red', blue=>'this is blue' );


To read config-files you could use http://search.cpan.org/~wadg/Config-IniFiles-2.38/. When it comes to the point of creating an Configuration-Class (e.g. to represent things like above) its common to use Singleton-Pattern.


But I can also think of reasons to have subroutines as well.  The module
would need to be available to all of the used modules, and I'd rather not
have to pass around a handle.  It also seems like it'd be nice if the
values were re-written, that it would only last for that session, but that
the change would be visible to all modules.

How do you guys deal with that?

What about a (or several) $dbh handle?  I'm going to have SQL queries in
all of my modules.  Do they all have to create their own $dbh?  Is there a
well understood approach to this that I'm not finding on the interweb?

Thanks again for all the help, I just seem to have a hard time building
complex perl systems the same way I used to under mod_perl 2.0, and need a
little experience and wisdom to make sure I head in mostly the right
direction.


As Perrin already said Apache::DBI or once more a Singleton-Class providing the DBH, although I'd use Apache::DBI because it handles everthing for you.


Nathanial Hendler
Tucson, AZ USA
http://retards.org/




--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to