[Catalyst] Reuse of controllers

Eden Cardim edencardim at gmail.com
Tue Sep 21 01:59:53 GMT 2010


>>>>> "Pavel" == Pavel A Karoukin <pavel at yepcorp.com> writes:

    Pavel> I got the basics from t0ms blog
    Pavel> (http://bobtfish.livejournal.com/#post-bobtfish-264317) An
    Pavel> example how i use it can be found here
    Pavel> http://wiki.catalystframework.org/wiki/wikicookbook/controllerwithfileupload
    Pavel> (the interesting part is in the file Resource.pm in the
    Pavel> attachment
    Pavel> http://wiki.catalystframework.org/wiki/wikicookbook/ControllerWithFileUpload.attachment/100)

An overlooked feature of Catalyst is the ability to modify actions via
the configuration:

package MyRole::Login;
use Moose::Role;

sub login { etc... }

package MyApp::Controller::Login;
use Moose;
with 'MyRole::Login';

__PACKAGE__->config(action => { login => { PathPart => 'sign-in' } } );

package MyOtherApp::Controller::Login;
use Moose;
with 'MyRole::Login';

__PACKAGE__->config(action => { login => { PathPart => 'log-in } } );

note that you can use any key that you would use as an action attribute,
including chainining, and catalyst automatically promotes the method to
an action due to the existence of the config.

-- 
   Eden Cardim       Need help with your Catalyst or DBIx::Class project?
  Code Monkey                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list