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:
====================
<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:
===========
package myapp::Model::DB;
use strict;
use Moose;
extends 'Catalyst::Model::DBIC::Schema';
with qw(Catalyst::TraitFor::Model::DBIC::ConfigPerSite);
__PACKAGE__->config(
traits => 'SchemaProxy',
);
around 'COMPONENT' => sub {
my ($orig, $class, $app, $args) = @_;
my $self = $class->$orig($app, $args);
$self->schema->source('Wcbfile')->column_info('wcbfiles_file')->{fs_column_path}
= $self->schema->file_path();
return $self;
};
1;
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/