[Catalyst] Re: [RFC] Loading Plugins from lib/MyApp/Plugins

Fayland Lam fayland at gmail.com
Wed Dec 19 05:11:26 GMT 2007


Christopher H. Laco wrote:
> Christopher Laco wrote:
>> I know I've been down this thread before. When writing a framework that
>> generates customized Catalyst apps, it would be a whole lot easier
>> (well, more proper) to add plugins in lib/MyApp/Plugins, just like we do
>> with controllers/models/view, than it is to molest the MyApp.pm 'use
>> Catalyst' line to include custom plugins.
>>
>> I'm assuming that it's just a matter of tweaking the Module::Pluggable
>> search paths at the appropriate time when Cat is starting up.
>>
>> Is this a planned feature for 5.8? Could it be?
>> Yes, I'll volunteer to put some tuits on it if need be.
>>
>> -=Chris
> 
> Just to keep the conversation rolling, let's put aside the Plugins
> directory for the moment.
> 
> If you wanted to load plugins from config, what would you like to see?
> What would you need?
> 
> 1. Load all plugins specifically from config, ignoring what's in
> MyApp.pm when specified?
> 
>   plugins:
>     - ConfigLoader
>     - Session
>     - Session::State::Cookie
>     - Session::Store::File
>     - +MyApp::Plugin::Frobnisicate
>     - Static::Simple
> 
> 

++;
but ConfigLoader need to load config?

generally we can do something like:

# MyApp.pm
use Catalyst qw/ConfigLoader/;

__PACKAGE__->setup(); # this would load __PACKAGE__->config;
if ( __PACKAGE__->config->{plugins} ) {
    __PACKAGE__->setup_plugins( __PACKAGE__->config->{plugins} );
}

that's it I think.



> 2. Load plugins from a location?
> 
>   plugins:
>     path: __path_to(lib, MyApp, Plugins)
> 
> 
> 3. Prepend/Append plugins to be loaded around MyApp.pm?
> 
>     plugins:
>       prepend:
>         - Debug
>       append:
>         - Static::Simple
>         - +MyApp::Plugin::Foo
> 
> -=Chris
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/


-- 
Fayland Lam // http://www.fayland.org/



More information about the Catalyst mailing list