CGI-Application-Plugin-DBH - CGI::Application::Plugin::ConfigAuto support

Posted on Thu Dec 15 00:05:58 2005 by perlmonkey
CGI::Application::Plugin::ConfigAuto support
The ::Plugin::DBH module is a nice addition to CGI::Application, but it would be nice to be able to use ::Plugin::ConfigAuto::cfg in addition to the application's param method. This could be done by adding the following to the __config_auto method:
my $params = $app->param('::Plugin::DBH::dbh_config'); if (!defined $params) { if (UNIVERSAL::can($app,'cfg')) { $params = $app->cfg('::Plugin::DBH::dbh_config'); if(!defined $params) { my $dsn = $app->cfg('db_dsn'); my $user = $app->cfg('db_user') || $app->cfg('db_username'); my $pass = $app->cfg('db_pass') || $app->cfg('db_password'); if ($dsn && $user) { $params = [$dsn,$user,$pass]; } } } } if (!$params || ref($params) ne 'ARRAY') { return __auto_config_env($app, $name); }

I would also require pass be present, but some people do have user='sa' and pass=''. It's a horrible practice, but not the module's job to enforce.
Write a response