Aaron James Trevena > Catalyst-TraitFor-Component-ConfigPerSite > Catalyst::TraitFor::Component::ConfigPerSite

Download:
Catalyst-TraitFor-Component-ConfigPerSite-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  2
View/Report Bugs
Module Version: 0.12   Source  

NAME ^

Catalyst::TraitFor::Component::ConfigPerSite - Extend Catalyst Components to share application accross sites

DESCRIPTIONS ^

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

SYNOPSIS ^

    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>

VERSION ^

0.12

METHODS ^

get_site_config

return (possibly cached) site-specific configuration based on host and path for this request

    my $site_config = $self->get_site_config($c);

get_component_config

return appropriate configuration for this component for this site

    my $config = $self->get_component_config;

get_from_instance_cache

    if (my $instance = $self->get_from_instance_cache($config)) {
        return $instance;
    }

put_in_instance_cache

    $self->put_in_instance_cache($config, $instance);

SEE ALSO ^

Catalyst::Component::InstancePerContext

Catalyst::TraitFor::View::TT::ConfigPerSite

Moose::Role

AUTHOR ^

Aaron Trevena, <aaron@aarontrevena.co.uk>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: