Catalyst::TraitFor::Component::ConfigPerSite - Extend Catalyst Components to share application accross sites
This Role or Trait allows you to share an application between sites, clients, etc with different configuration for templates and databases (and possibly other parts).
Compose this role into your trait to extend a catalyst component such as a model or view
in testblogapp.conf: name TestBlogApp site_name TestBlog default_view TT <Model::DB> schema_class TestBlogApp::Schema <connect_info> dsn dbi:SQLite:dbname=t/test.db user username password password </connect_info> </Model::DB> <View::TT> TEMPLATE_EXTENSION .tt WRAPPER site-wrapper.tt INCLUDE_PATH t/templates </View::TT> <TraitFor::Component::ConfigPerSite> <foo.bar> <Model::DB> schema_class TestBlogApp::Schema <connect_info> dsn dbi:SQLite:dbname=t/test2.db user username password password </connect_info> instance_cache_key foo_bar_model_db </Model::DB> <View::TT> TEMPLATE_EXTENSION .tt WRAPPER site-wrapper.tt INCLUDE_PATH t/more_templates instance_cache_key foo_bar_view_tt </View::TT> </foo.bar> </TraitFor::Component::ConfigPerSite>
0.12
return (possibly cached) site-specific configuration based on host and path for this request
my $site_config = $self->get_site_config($c);
return appropriate configuration for this component for this site
my $config = $self->get_component_config;
if (my $instance = $self->get_from_instance_cache($config)) { return $instance; }
$self->put_in_instance_cache($config, $instance);
Catalyst::Component::InstancePerContext
Catalyst::TraitFor::View::TT::ConfigPerSite
Moose::Role
Aaron Trevena, <aaron@aarontrevena.co.uk>
Copyright (C) 2010-2013 by Aaron Trevena
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install Catalyst::TraitFor::Component::ConfigPerSite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::TraitFor::Component::ConfigPerSite
CPAN shell
perl -MCPAN -e shell install Catalyst::TraitFor::Component::ConfigPerSite
For more information on module installation, please visit the detailed CPAN module installation guide.