[Catalyst] Catalyst-TraitFor-Component-ConfigPerSite - How to access additional per-site config parameters

Nick nick at webcraftcs.com
Tue Jun 26 15:30:02 GMT 2012


Using the Catalyst-TraitFor-Component-ConfigPerSite modules, I am able =

to set up various database connections on a per-site basis and this =

works well.

Can anyone tell me how I can extend this to access additional per-site =

information from the config file which will allow me to e.g. set up =

per-site file_paths to feed into the fs_column_path (using =

<http://search.cpan.org/perldoc?DBIx%3A%3AClass%3A%3AInflateColumn%3A%3AFS>=
DBIx::Class::InflateColumn::FS) =

within the Model::DB package?

Currently, $self->schema->file_path() extracts the config item from the =

default <Model::DB> section. I want to extract the file_path from the =

website1 section of the config file.

Any help would be greatly appreciated.

Thank you.


Currently, my config file contains:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

<Model::DB>
   schema_class default::Schema
<connect_info>
     dsn dbi:mysql:defaultdb
     user xxxx
     password xxxx
</connect_info>
     file_path /path/to/site/default
</Model::DB>

<TraitFor::Component::ConfigPerSite>
<website1.com>
<Model::DB>
             schema_class website1::Schema
<connect_info>
                 dsn dbi:mysql:website1db
                 user xxxx
                 password xxxx
</connect_info>
             instance_cache_key website1_model_db
             file_path /path/to/site/website1
</Model::DB>
</website1.com>
</TraitFor::Component::ConfigPerSite>


The DB model file:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
package myapp::Model::DB;

use strict;
use Moose;
extends 'Catalyst::Model::DBIC::Schema';
with qw(Catalyst::TraitFor::Model::DBIC::ConfigPerSite);

__PACKAGE__->config(
     traits       =3D> 'SchemaProxy',
);

around 'COMPONENT' =3D> sub {
     my ($orig, $class, $app, $args) =3D @_;
     my $self =3D $class->$orig($app, $args);
     =

$self->schema->source('Wcbfile')->column_info('wcbfiles_file')->{fs_column_=
path} =

=3D $self->schema->file_path();
     return $self;
};


1;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20120626/b7860=
b1a/attachment.htm


More information about the Catalyst mailing list