[Dbix-class] RFC: DBIx::Class 0.05 Schemas + Catalyst?

Brandon Black blblack at gmail.com
Wed Feb 1 16:56:52 CET 2006


On 2/1/06, Jess Robinson <castaway at desert-island.demon.co.uk> wrote:
>
> I'm currently using a DBIC setup which supports $c->model('MyModelBase')
> and even $c->model('Schema::MyClass');
>
> Using msts new COMPONENT and ACCEPT_CONTEXT thingys for Catalyst, it works
> like this:
>
> MyApp::Model::MyModelBase uses My::Schema, which is elsewhere, and
> contains:
> sub COMPONENT
> {
>     my ($class, $c, $config) = @_;
>
>     my $schema =
> My::Schema->compose_connection('MyApp::Model::Schema',
> 'dbi:mydb:dbname',, 'user', 'passw');
>     return $schema;
> }
>
> which makes $c->model('MyModelBase') work..
> and the MyApp::Model::Schema::MyClass contains:
>
> sub ACCEPT_CONTEXT
> {
>   my ($self, $c) = @_;
>
>   return $c->model('MyModelBase')->resultset('MyClass');
> }
>
> which makes $c->model('Schema::MyClass') work..
>
> So maybe we just need a Helper that creates these..
>
> Jess

I suspect your COMPONENT/compose_connection thing leads to the
inability to have multiple instances of the app under a single apache
server with different connections, but I could be wrong.  The
ACCEPT_CONTEXT stuff you're doing is essentially the same as the base
model I last attached - but mine just iterates the existing Schema
monikers and inserts the ACCEPT_CONTEXT for you, rather than needing
them defined externally.

I think in one more iteration I can probably get rid of model->schema
again, and make the model object be the schema and still get all the
advantages, but it's not there yet.

-- Brandon



More information about the Dbix-class mailing list