[Catalyst] Catalyst::Plugin::Authentication::Store::DBIC and config in auto
Brandon Black
blblack at gmail.com
Thu Mar 23 06:35:05 CET 2006
On 3/22/06, fayland <fayland at gmail.com> wrote:
> hi, all.
> Since we use more than one database server, I need to connect database
> in sub auto of Root.pm.
> so I config the Catalyst::Plugin::Authentication::Store::DBIC after the
> connect like this:
>
> sub auto : Private {
> my ( $self, $c ) = @_;
>
> # connect db
> $c->forward('init');
>
> use Data::Dumper;
>
> $c->log->debug(Dumper($c->config->{dbic}{geo}->resultset('User')->search({})->first));
> $c->config->{authentication}{dbic} = {
> user_class => $c->config->{dbic}{geo}->resultset('User'),
> user_field => 'username',
> password_field => 'password',
> };
>
> the debug screen shows that ->resultset('User')->search({})->first
> works. but the Catalyst::Plugin::Authentication::Store::DBIC complains :
> |
> Caught exception in Zorpia::Controller::User->login "Can't call method
> "search" on an undefined value at
>
> any suggestion? can I config the DBIC in the auto?
>
> Thanks. any tip is appreciated very much.
>
For many (most? all?) plugins (and models and views), ->config values
can't effectively be changed after ->setup occurs I think. I would
imagine there's a more efficient and effective way of doing things
than connecting to the db in Root::auto in any case.
What's the story with the multiple DBs? Are we talking a fixed set of
3-4, or a dynamic set of databases created by users while they use the
app, or what? The DBIC::Schema model allows for making seperate
models for different static connections that all share the same schema
easily, and also provides a cloning mechanism for getting new $schemas
from new connection info at runtime.
-- Brandon
More information about the Catalyst
mailing list