[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 =

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:

   schema_class default::Schema
     dsn dbi:mysql:defaultdb
     user xxxx
     password xxxx
     file_path /path/to/site/default

             schema_class website1::Schema
                 dsn dbi:mysql:website1db
                 user xxxx
                 password xxxx
             instance_cache_key website1_model_db
             file_path /path/to/site/website1

The DB model file:
package myapp::Model::DB;

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

     traits       =3D> 'SchemaProxy',

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

path} =

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

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

More information about the Catalyst mailing list