Hi,
I am fairly new to all things Perl and Catalyst, and would like to know
if what I am attempting to do is correct.
I've recently finished reading 'The Definitive Guide to Catalyst', which
has been very helpful, but I am still a little confused about separating
my business logic from my Catalyst application, and accessing the
database connection from my non-Catalyst application.
At the moment, I have my external class in the lib/MyApp directory. It
uses the connection info found in MyApp::Model::DB, like so:
---
# lib/MyApp/MyExternalClass.pm
MyApp::MyExternalClass
use MyApp::Model::DB;
use MyApp::Schema;
my $connect_info = MyApp::Model::DB->config->{connect_info};
my $schema = MyApp::Schema->connect( $connect_info );
# Do stuff with $schema...
---
That works, and I can connect to the database. However, I have searched
this mailing list, and found this:
http://www.mail-archive.com/[email protected]/msg00817.html
Here, the connection information is moved from MyApp::Model::DB to
MyApp::DB, and then Catalyst::Model::Adaptor is used to glue
MyApp::Model::DB to MyApp::DB. Is it a good idea? MyApp::Model::DB
appears to be part of the Catalyst application, so if I want to access
the database from an external model, it makes sense to me to move the
connection code outside of the Catalyst application.
Regards,
Mike
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/