Sven,
Seems to me this would work well as a plugin (C::P: BConnect
or?) with
the a setup method to "push" your global
"databaseconfig" options into
the appropriate config option for each model.
Something like...
package Catalyst::Plugin: BConnect
or;
sub setup {
my $c = shift;
foreach my $model ($c->models) {
$c->config->->{$model}-> =
$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: BIC::Sch
ema, 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->->
>
> 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 lists.rawmode.org
> Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
> Dev site: http://dev.catalyst.per
l.org/
--
Matthew Pitts <mpitts a3its.com>
A3 IT Solutions, LLC
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|