[Catalyst] Model classes based on external Class::DBI modules
Ken Youens-Clark
kyclark at gmail.com
Tue Oct 25 00:08:55 CEST 2005
Hi,
In trying to learn Catalyst, I've copied the Hops example CRUD app
and have been hacking on that. I want to use my own Class::DBI
classes defined outside of Catalyst as described here:
http://search.cpan.org/~agrundma/Catalyst-5.49_01/lib/Catalyst/
Manual/Intro.pod
> ...since many people have existing Model classes that they would
> like to use with Catalyst (or, conversely, they want to write
> Catalyst models that can be used outside of Catalyst, e.g. in a
> cron job), it's trivial to write a simple component in Catalyst
> that slurps in an outside Model:
>
> package MyApp::M::Catalog;
> use base qw/Catalyst::Base Some::Other::CDBI::Module::Catalog/;
> 1;
I have one file that contains all my Class::DBI classes that looks
kinda like this:
> package QTL::CDBI;
>
> use Class::DBI;
>
> use base qw( Class::DBI );
>
> QTL::CDBI->connection( ... );
>
> # ------------------------------------------------
> package QTL::CDBI::Qtl;
>
> use base qw( QTL::CDBI );
>
> QTL::CDBI::Qtl->table('qtl');
> ...
> # ------------------------------------------------
> package QTL::CDBI::QtlDbxref;
>
> use base qw( QTL::CDBI );
>
> QTL::CDBI::QtlDbxref->table('qtl_dbxref');
> ...
>
> 1;
In my "QTL::M::CDBI" module, I have this:
> package QTL::M::CDBI;
>
> use lib '/home/kclark/lib';
>
> use base qw( Catalyst::Base QTL::CDBI );
>
> 1;
But when I try to use my app, I'm getting this error on "/catalyst/
qtl/qtl/list/":
Caught exception "Can't locate object method "loader" via package
"QTL::M::CDBI" at /home/kclark/work/catalyst/QTL/lib/QTL.pm line 21."
I also tried adding "Catalyst::Model::CDBI::Plain" to the mix, but
that didn't fix anything.
What am I missing?
ky
More information about the Catalyst
mailing list