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

Adam Witney awitney at sgul.ac.uk
Wed Mar 11 12:03:53 GMT 2009


On 11 Mar 2009, at 11:23, Adam Witney 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

ok, so i posted too soon and have figured out the problem. I need to  
add "Result" into the relationships. Does the Tutorial need to be  
updated to reflect this? If so i have included below a quick patch  
against

http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod

HTH

adam


------------------------------------------------------------------------------------------------------------------------------------------

1108c1108
< class" files from the C<lib/MyApp/Schema> subdirectory.  The end
---
 > class" files from the C<lib/MyApp/Schema/Result> subdirectory.  The  
end
1129c1129
< this step.)  First edit C<lib/MyApp/Schema/Books.pm> and add the
---
 > this step.)  First edit C<lib/MyApp/Schema/Result/Books.pm> and add  
the
1141c1141
<     __PACKAGE__->has_many(book_authors =>  
'MyApp::Schema::BookAuthors', 'book_id');
---
 >     __PACKAGE__->has_many(book_authors =>  
'MyApp::Schema::Result::BookAuthors', 'book_id');
1181c1181
< Then edit C<lib/MyApp/Schema/Authors.pm> and add relationship
---
 > Then edit C<lib/MyApp/Schema/Result/Authors.pm> and add relationship
1194c1194
<     __PACKAGE__->has_many(book_author =>  
'MyApp::Schema::BookAuthors', 'author_id');
---
 >     __PACKAGE__->has_many(book_author =>  
'MyApp::Schema::Result::BookAuthors', 'author_id');
1205c1205
< C<lib/MyApp/Schema/BookAuthors.pm>:
---
 > C<lib/MyApp/Schema/Result/BookAuthors.pm>:
1216c1216
<     __PACKAGE__->belongs_to(book => 'MyApp::Schema::Books',  
'book_id');
---
 >     __PACKAGE__->belongs_to(book => 'MyApp::Schema::Result::Books',  
'book_id');
1223c1223
<     __PACKAGE__->belongs_to(author => 'MyApp::Schema::Authors',  
'author_id');
---
 >     __PACKAGE__->belongs_to(author =>  
'MyApp::Schema::Result::Authors', 'author_id');






More information about the Catalyst mailing list