[Catalyst] CDBI integration

Bill Moseley moseley at hank.org
Tue Jun 13 15:51:14 CEST 2006


On Fri, Jun 09, 2006 at 12:58:14PM -0700, Pablo Collins wrote:
> 
> I have a bunch of Class::DBI packages in a directory/namespace outside of
> the catalyst app I'm building and I would like to make them available as the
> model layer.
> 
> It looks like if you want a model layer in catalyst, each class has to be
> inside the top-level namespace of the application. I would prefer to not
> have to create a package for each catalyst model class that says "package
> MyApp::Model::Foo; use base 'MyModel::Foo';" for each package. It would be
> neat if you tell the config where your model files live and have catalyst
> slurp them up.

I don't use $c->model to refer to my CDBI classes, so all I do in
Catalyst to connect to the model is this:

    package MyApp::M::CDBI;
    use DB;
    DB->new( MyApp->config->{database} );

Where "DB" is the CDBI base class and new() sets up the parameters
from the application config and calls connection();


-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list