[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Re: DBH plugin configuration


On 2005-02-22, Thilo Planz <suppressed> wrote:
>
>> use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
>>
>>  sub cgiapp_init  {
>>     my $self = shift;
>>     # get the params
>>     my $data_source = $self->param('data_source');
>>     my $username = $self->param('data_source_user');
>>     my $auth = $self->param('data_source_pass');
>>
>>    # use the same args as DBI->connect();
>>     $self->dbh_config($data_source, $username, $auth. { SomeAttr => 
>> 1});
>> }
>
> I think it should be possible to completely get rid of all this code by 
> having some naming conventions
> for the CGI::App instance  parameters.
> The plugin could then bootstrap itself from the parameters of the 
> instance.
>
> my $app = new MyCGIApp;
> $app->param (
> 	'::Plugin::DBH' =>
> 		{ data_source => [ 'dbi:...', 'blah', 'blah' ] }
> );
>
> dbh_config could use these parameters to connect to the DB.
> It would only do this unless explicitly configured, which makes this a 
> backwards-compatible feature.
>
> The "::Plugin::DBH" data_source parameter could also take a hash of 
> arrays to accomodate named handles.
>
> Not everyone is setting parameters in the instance script. Some people
> are using configuration files in various formats that get more or less
> automagically (code-free) included.  This kind of plugin
> autoconfiguration would also integrate nicely with those.
>
> Am I making sense to anyone?

I think your suggestion makes sense for people who want to configure
their DBH handles through the instance script, rather than through a
config file. 

I think I would accept a patch for this functionality to '::Plugin::DBH'
if you wanted to make it work. I can't say I'm excited enough to code it
myself, though. :)

    Mark

-- 
http://mark.stosberg.com/ 


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.