[Catalyst] Gluing with Catalyst::Model::Adaptor
Cedric Boudin
cedric at dreamgnu.com
Tue Dec 11 17:16:24 GMT 2007
Dear list members,
Reading Jonathans last post:
"Catalyst::Model::Adaptor - because models shouldn't *do* anything"
I couldn't resist trying to use it.
I've been trying to push out of my C::Classes all this resutset stuff
that I rather see in the DBIx classes where they belong.
What did I do:
I tried to follow the description on CPAN.
1)In my 'DBIx::Class::Schema' class where I load all the component for
the DBIx stuff I added the
------------------
package CatalEgo::Db
use strict;
use warnings;
use DBIx::Class::Schema;
++use Moose;
__PACKAGE__->load_classes;
1;
------------------
2)In the Myapp::M::Db.pm file where I configure the DBix connection
stuff I added
-------------------------------
package CatalEgo::M::CatalEgoDb;
++use base 'Catalyst::Model::Adaptor';
__PACKAGE__->config(
schema_class => 'CatalEgo::Db',
connect_info => [
'dbi:Pg:dbname=.....',
'USER,
'passwd',
],
);
++__PACKAGE__->config( class => 'CatalEgo::Db' );
1;
----------------------------------
and I do get at server start:script/catalego_server.pl
Couldn't instantiate component "CatalEgo::M::CatalEgoDb", "Cannot load
schema class 'CatalEgo::Db': Can't use an undefined value as a HASH
reference at
/home/ced/perl/lib/perl5/share/perl/5.8.8/Class/MOP/Class.pm line 428.
BEGIN failed--compilation aborted at /usr/share/perl5/Moose/Object.pm
line 8.
Compilation failed in require at /usr/share/perl5/Moose.pm line 24.
BEGIN failed--compilation aborted at /usr/share/perl5/Moose.pm line 24.
Compilation failed in require at
/cedplay_ground/wd/CatalEgo/lib/CatalEgo/Db.pm line 9.
BEGIN failed--compilation aborted at
/cedplay_ground/wd/CatalEgo/lib/CatalEgo/Db.pm line 9.
Compilation failed in require at
/usr/share/perl5/Catalyst/Model/DBIC/Schema.pm line 272.
at script/catalego_server.pl line 56" at script/catalego_server.pl line 56
Compilation failed in require at script/catalego_server.pl line 56.
Obviously I'm doing somethig wrong. Or I did not get the whole picture.
Do I have to:
for all Classes I have in my DBIx part make their counterpart in the
Myapp::M::...
That is:
CatalEgo::Db:Table1 -> CatalEgo::M::Table1
CatalEgo::Db:Table2 -> CatalEgo::M::Table2
CatalEgo::Db:Table3 -> CatalEgo::M::Table3
Is it possible just to glue my whole DBIx::Model in one go into catalyst
so that I can use it as I use it as standalone outside the catalkyst
environment.
some hints, encouragement (=:) are most welcome
cheers
cedric
More information about the Catalyst
mailing list