[Catalyst] C::P::A::Store::DBIC and Schema support
Brandon Black
blblack at gmail.com
Sun Feb 19 16:38:54 CET 2006
On 2/19/06, Alex Kavanagh <alex at tinwood.homelinux.org> wrote:
> Hi
>
> My dislocated shoulder has finally healed enough to type again ...
>
> Anyway, I checked the trunk for
> Catalyst::Plugin::Authentication::Store::DBIC with DBIx::Class::Schema
> support because I had been working on something similar before my
> accident. I found that there was some changes in trunk with
> 'dbic_schema' config.
>
> The relevant lines in C::P::A::S::D::User are:
>
> my $user_class = $config->{auth}->{dbic_schema}
> ? $config->{auth}->{dbic_schema}->resultset( $config->{auth}->{user_class} )
> : $config->{auth}->{user_class};
> my $user_obj = $user_class->search( { $config->{auth}->{user_field} => $id } )->first;
>
> For this to work, the $config->{auth}->{dbic_schema} needs to be a
> DBIx::Class object connected to a database.
>
> The thing is:
>
> How do I set this up?
>
> Before I delved too deeply, I tried my set up as:
>
> __PACKAGE__->config->{authentication}->{dbic} = {
> dbic_schema => 'SiteDBIxSchema::Schema',
> user_class => 'Users',
> user_field => 'username',
> password_field => 'password',
> password_type => 'clear', # will be 'hashed'
> password_hash_type => 'SHA-1',
> };
>
> where SiteDBIxSchema::Schema is the schema for the database
> (e.g. SiteDBIxSchema::Schema-connect(...) gives an object that
> resultset works on. and 'Users' is the Users table.
>
> However, (obviously) this doesn't work.
>
> Anybody know how to configure this module to work with
> DBIx::Class::Schema ??
>
> My version of the schema support involved caching the '$c' when the
> 'User.pm' object was created in C::P...::DBIC.pm and this allowed me
> to use var->model( <config_model> ) where <config_model> was
> 'SiteDB::Users' and SiteDB was the namespace for the Schema.
>
> I can't quite work out where to get the Schema object from to get it
> into the config so that the Plugin will actually work.
>
I don't know anything about the current implementation(s), but if I
were doing it, I'd probably have the config argument for the schema be
a model name rather than a schema class. Anything that needs db
access in Cat should be using models rather than directly using
external stuff imho. Your model could then be a C::M::DBIC::Schema
that has connection information.
-- Brandon
More information about the Catalyst
mailing list