[Catalyst] Catalyst modperl - child process segmentation fault

Marcello Romani mromani at ottotecnica.com
Thu Jan 8 10:57:57 GMT 2009


Terence Monteiro ha scritto:

[snip]

> not happen? I am initializing the database connection in a Controller. Is
> there any problem in this, though it may not be the best design. Will
> putting the database initialization code in the Model help? I have included

afaict, you should let dbic / cat-model handle the connection to the 
database. I usually use something like this: a

MyApp/Model/Main.pm

package which inherits from e.g.

Catalyst::Model::DBIC::Schema

and calls

__PACKAGE__->config(
	schema_class => 'MyApp::Schema',
	connect_info => [ $dsn, $user, $pass, $options ],
);

This way I don't explicitly connect at startup, but let the framework 
perform the actual connection when needed (i.e. at first db access, with 
something like $c->model('Main')->resultset('Users')->find($id))

[snip]

HTH

-- 
Marcello Romani
Responsabile IT
Ottotecnica s.r.l.
http://www.ottotecnica.com



More information about the Catalyst mailing list