[Dbix-class] Problem with external model,
"Can't call method 'select' on an undefined..."
Ekki Plicht (df4or)
ep at plicht.de
Fri Sep 16 22:52:09 GMT 2011
Hi.
In a Catalyst app I try to use an external database (external to the
App namespace). I followed the example in THEBOOK (Def.Guide to
Catalyst; Extracting the Model/Moving the Model Logic into an
Application-Independent Class, pg.83).
The extracted model lives in a directory, which is included in
PERL5LIB environment variable and therefore in @INC.
~/perllib/ShopDB.pm
~/perllib/ShopDB/Result/Order.pm
~/perllib/ShopDB/Result/Customer.pm
~/perllib/ShopDB/Result/Article.pm
This schema works fine, I use it in a non-Catalyst app without
problems. The database is populated with data.
In my C::App called 'Intranet' I use the following adaptor model located here:
~/Intranet/lib/Intranet/Model/ExtShopdb.pm
(Contents of this file see below)
The schema is created by $schema = $c->model('ExtShopdb');
The resultset is created by $rs = $schema->resultset('Order');
(I know that I can combine this into one statement).
When trying simple things like:
$rs->search({ date => '2004-01-01'})->all;
I get an error:
"Can't call method "select" on an undefined value at
/usr/local/share/perl/5.10.1/DBIx/Class/ResultSet.pm line 901."
Another simple test fails as well:
$rs->search()->count;
yields "Can't call method "_count_select" on an undefined value..."
Checked/Tried so far:
- The resultset is defined (otherwise the ->search call above would
fail, the resultset looks good when I look at a dump.)
- DBIC_TRACE=1 used when calling the internal catalyst_server, no
diags visible from DBIC.
- googled for the error message, found a thread from catalyst_de list
from 2009, recommending the use of ->load_classes(); it seemed to help
the OP. That's where I get lost.
Versions:
perl 5.10.1
DBIx::Class 0.08192
Any help (pointers where I go wrong) are greatly appreciated.
Cheers & TIA,
Ekki
###########################
# Contents of ExtShopdb.pm
package Intranet::Model::ExtShopdb;
use strict;
use warnings;
use base 'Catalyst::Model::Adaptor';
__PACKAGE__->config(
class => 'ShopDB',
connect_info => {
dsn => 'dbi:mysql:mydatabase',
user => 'someuser',
password => 'somepasswd',
AutoCommit => q{1},
}
);
1;
##################
# Contents of ShopDB.pm
package ShopDB;
use strict;
use warnings;
use Moose;
use base 'DBIx::Class::Schema';
__PACKAGE__->load_namespaces;
1;
##########################
More information about the DBIx-Class
mailing list