[Catalyst] Problem with static model in Tutorial::MoreCatalystBasics

hkclark at gmail.com hkclark at gmail.com
Wed Mar 11 16:26:33 GMT 2009


On Wed, Mar 11, 2009 at 7:23 AM, Adam Witney <awitney at sgul.ac.uk> wrote:
> Hi,
>
> I am new to Catalyst and so working my way through the tutorial. Everything
> has been working fine until i reached the "A STATIC DATABASE MODEL WITH
> DBIx::Class" section of the MoreCatalystBasics tutorial.
>
> After generating the static schema files and adding the relationships as
> directed, running the test server causes this error:
>
> mrc1-181:MyApp adam$ script/myapp_server.pl
> Couldn't instantiate component "MyApp::Model::DB", "Cannot load schema class
> 'MyApp::Schema': DBIx::Class::Schema::throw_exception():
> DBIx::Class::Row::throw_exception(): Can't locate MyApp/Schema/Authors.pm in
> @INC (@INC contains:
> /Library/WebServer/Documents/Catalyst/MyApp/script/../lib
> /Library/Frameworks/R.framework/Resources/library/RSPerl/perl/darwin-thread-multi-2level
> /usr/local/install/Ensembl/ensembl/modules/
> /usr/local/install/Ensembl/ensembl-compara/modules/
> /usr/local/lib/perl5/5.8.9/darwin-thread-multi-2level
> /usr/local/lib/perl5/5.8.9
> /usr/local/lib/perl5/site_perl/5.8.9/darwin-thread-multi-2level
> /usr/local/lib/perl5/site_perl/5.8.9 .) at
> /usr/local/lib/perl5/site_perl/5.8.9/Class/C3/Componentised.pm line 126.
> Compilation failed in require at
> /usr/local/lib/perl5/site_perl/5.8.9/Class/C3/Componentised.pm line 126.
> Compilation failed in require at
> /usr/local/lib/perl5/site_perl/5.8.9/Catalyst/Model/DBIC/Schema.pm line 333.
>  at script/myapp_server.pl line 55" at script/myapp_server.pl line 55
> Compilation failed in require at script/myapp_server.pl line 55.
>
> I think the problem is that my Authors.pm, Books.pm and BookAuthors.pm were
> all created in MyApp/Schema/Result/ rather than MyApp/Schema/ which is what
> the Tutorial seems to expect (as shown by the line "edit
> lib/MyApp/Schema/Books.pm")
>
> I'm not sure if this is a DBIx::Class issue or a Catalyst issue. Does anyone
> know how to rectify this problem?
>
> DBIx::Class = 0.08012
> Catalyst = 5.71000
>
> thanks for any help
>
> adam
>

Hi,

Yeah, the most recent version of Catalyst::Model::DBIC::Schema
defaults to "load_namespaces", so that's the problem.  The tutorial
was written assuming the user was following along with Debian, which
currently has an older version.  I'm guessing we might want to add the
logic to Catalyst::Helper::Model::DBIC::Schema to force it to do
"load_classes" (maybe do that if "use_namespaces=0" is on the command
line).  But, either way, I guess the best thing to do is to have the
user do "sudo cpan Catalyst::Model::DBIC::Schema" in
MoreCatalystBasics.pod so we start out with "load_namespaces" right
away vs. the current approach where we do "load_classes"
MoreCatalystBasics.pod and migrate to "load_namespaces" in
BasicCRUD.pod.  I'll start working on those changes now (I think I can
get an update posted to CPAN later today).

Kennedy



More information about the Catalyst mailing list