[Catalyst] Model configuration through .yml

Stuart Watt swatt at infobal.com
Wed Jan 13 14:55:50 GMT 2010

It certainly is possible. We do it that way, with two YAML config files. 
One has the schema_class (this is the one in the home area) and the 
second has the connect_info (I guess the typed "connect_into" is just a 
typo), which we put in a separate file in the site's directory, so we 
can run several sites, only changing the db connection info. I can't see 
an obvious explanation from these snippets, but it looks more like the 
module loading is the problem, not the configuration. Maybe check the 
modules load from a debugged Perl starting your app and then a manual 
"use Schema::MyApp;"?

I've kind of gone off YAML for configuration, but since it took me 2 
years to get my colleagues to edit them rather than raw Perl code, can't 
change now.


Emmanuel Quevillon wrote:
> Hi,
> I'd like to know something, probably a basic problem but just to be sure.
> Is it possible to configure Application db connection into .yml 
> configuration file like :
> Model::MyAppDB
>     schema_class: Schema::MyApp
>     connect_into:
>     - dbi:Pg:dbname=myapp
>     - user
>     - password
>     - options
> Actually i tried this way but I cannot connect to the database, 
> neither start my application, perl is not able to locate my schema 
> class...!!
> Here is the error:
> Couldn't load class (Schema::MyApp) because: Couldn't instantiate 
> component "BiblioList::Model::MyAppDB", "Can't locate Schema/MyApp.pm 
> in @INC
> I can make it working if I add into Model::MyApp this :
> __PACKAGE__->config( ... );
> I first did it, just adding 'schema_class' infos and leaving 
> connect_info into config file and it works like a charm.
> However, the strange thing is that, other db connection I configured 
> for other databases can connect correctly even if I use another Schema 
> module like Schema::FooBarDB located under the same directory as 
> Schema::MyApp
> For example in another confg file I load using 
> C::Plugin::ConfigLoader::Multi
> I can define this
> Model::RemoteDB::AnotherDB:
>     schema_class: Schema::FooBarDB
>     connect_info:
>         - ..
> and it connect correctly to my foobardb without throwing errors above.
> Is this normal behavior from Catalyst or is there something I am doing 
> wrong or just a bug?
> Thanks for any hint.
> Regards
> Emmanuel
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: 
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> -- 
> This message was scanned by ESVA and is believed to be clean.
> Click here to report this message as spam. 
> http://antispam.infobal.com/cgi-bin/learn-msg.cgi?id=EDF782807B.A15EF

More information about the Catalyst mailing list