[Dbix-class] Catalyst::Model::DBIC::Schema 0.03

Brandon Black blblack at gmail.com
Thu Feb 9 09:00:29 CET 2006


Snaphot is avail at http://www.dtmf.com/Catalyst-Model-DBIC-Schema-0.03.tar.gz

The major change is the addition of a new Helper class called
Catalyst::Helper::Model::DBIC::SchemaInlineLoader

This comes close to emulating what Catalyst::Helper::Model::DBIC did,
in that it generates a model-class with no external dependancies,
which is loaded via a Loader.

Usage is:

script/create.pl model MyModel DBIC::SchemaInlineLoader dsn user password

And the output class looks like:

MyApp/M/MyModel.pm ------------------------------

package _MyApp::M::MyModel::Schema;

use strict;
use base qw/DBIx::Class::Schema::Loader/;

__PACKAGE__->load_from_connection(
    dsn     => 'dbi:Pg:dbname=modeltest',
    user    => 'postgres',
    pass    => '',
    options => {
                  RaiseError         => 1,
                  PrintError         => 0,
                  ShowErrorStatement => 1,
                  TraceLevel         => 0,
                  AutoCommit         => 1,
                },
    relationships => 1,
    # debug => 1,
);

package MyApp::M::MyModel;

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

__PACKAGE__->config(
    schema_class => '_MyApp::M::MyModel::Schema',
);

1;

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

I know the _Class thing is ugly.  I couldn't think of a better way at
the moment to generate a class on the fly in a unique namespace that
doesn't wind up being "seen" by Catalyst as a component itself, given
that I only have the Model classname to work with from the start. 
Perhaps something else slightly less ugly would be better, like
MyApp::_Model::MyModel::Schema, or MyApp::_LoaderModel::, etc...

Any thoughts on that would be appreciated,

-- Brandon



More information about the Dbix-class mailing list