[Catalyst] C::M::DBIC::Schema external configuration
Matthew Pitts
mpitts at a3its.com
Thu May 31 15:48:59 GMT 2007
Sven,
Seems to me this would work well as a plugin (C::P::DBConnector?) with
the a setup method to "push" your global "databaseconfig" options into
the appropriate config option for each model.
Something like...
package Catalyst::Plugin::DBConnector;
sub setup {
my $c = shift;
foreach my $model ($c->models) {
$c->config->{Model}->{$model}->{connect_info} =
$c->get_databaseconfig()
}
}
1;
Of course, you've need to write the get_databaseconfig() method to
extrapolate your "databaseconfig" into a structure compatible with
connect_info.
Have fun.
-matt pitts
On Thu, 2007-05-31 at 16:09 +0200, Sven Eppler wrote:
> Hello There!
>
> I've got a (hopefully) quite easy question :)
>
> If i wanted to have my database connection information seperated from the
> code in my myApp.yml file for Catalyst::Model::DBIC::Schema, how would i
> actually do that?
>
> Of course i could do:
>
> Model:
> MyDB:
> connect_info:
> - DSN
> - USER
> - PASSWORD
>
> But actually i don't like it this way. Also i will have to add the
> AutoCommit => 1 stuff into the "userconfig" (and obviously i don't want
> such internals to be tweaked by a novice user).
>
> I would prefer to have just three questionable parameters: Databasename,
> username and password? I tried in my myApp.yml file:
>
> databaseconfig:
> username: blah
> password: foo
> databasename: bar
>
> And then in my Model:
> __PACKAGE__->config->{databaseconfig}->{username}
>
> but this actually doesn't work?
>
> Anybody some idea to have this seperated from the code in a way, even some
> kind of dummy-webmaster could set the application up?
>
> Thans in advance,
> Sven
>
>
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
--
Matthew Pitts <mpitts at a3its.com>
A3 IT Solutions, LLC
More information about the Catalyst
mailing list