[Catalyst] connection info and Catalyst::Model::DBIC::Schema

Alan Humphrey alan.humphrey at comcast.net
Thu Aug 3 21:51:08 CEST 2006


I feel that I'm missing something obvious, but the penny hasn't dropped.
Hope you all can help.

Goal: use a DBIx::Class schema defined outside the Catalyst app name space.

Using: Catalyst::Model::DBIC::Schema

Problem: I have to define the connection information in my Catalyst
definition:

package Engoi::Model::Schema;

use strict;
use base 'Catalyst::Model::DBIC::Schema';

__PACKAGE__->config(
    schema_class => 'Engoi::Schema::EngoiDbDev',
    connect_info => [
        'dbi:Pg:dbname=engoidev',
        'user',
        'xxxx',
        
    ],
);

If I comment out the connection info I get the following error on app
startup:

Couldn't instantiate component "Engoi::Model::Schema", "Can't locate object
method "storage" via package "Engoi::Schema::EngoiDbDev"

Engoi::Schema::EngoiDbDev look like:

package Engoi::Schema::EngoiDbDev;

use strict;
use warnings;
use Engoi::Schema::EngoiDb;

my @conn_info = (
        'dbi:Pg:dbname=engoidev',
        'user',
        'xxxx',
    { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel
=> 0 }
);

Engoi::Schema::EngoiDb->compose_connection( __PACKAGE__, @conn_info );

1;

I'd like to be able to keep the connection info here, not in
Engoi::Model::Schema to make it easier to use the  schema in non-Catalyst
apps.

The C::M::D::S docs say this about connect_info

This is not required if schema_class already has connection information
defined inside itself (which isn't highly recommended, but can be done)

So, why isn't this recommended and how is it done?

Thank you!

- Alan




More information about the Catalyst mailing list