Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Catalyst - components from other namespace

by roman (Monk)
on Mar 17, 2011 at 16:29 UTC ( [id://893805]=perlquestion: print w/replies, xml ) Need Help??

roman has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

is there a sane way how to make Catalyst application use controllers, views or models from other namespace?

Imagine MyApp, YourApp applications which want to use OurApp::Controller::Request, OurApp::View::Mason, OurApp::Model::Customer components.

I can easily load the components:

__PACKAGE__->config( setup_components => { search_extra => [qw(OurApp::Controller OurApp::Model OurApp::V +iew)], } );

But I would also like the loaded components to be reached via $c->view('Mason'), $c->model('Customer::Request'), $c->controller('Request') and let the Mason view be the default one.

Has anyone dealt with a similar situation? I appreciate any advice.

Replies are listed 'Best First'.
Re: Catalyst - components from other namespace
by stonecolddevin (Parson) on Mar 17, 2011 at 17:43 UTC

      It seems that CatalystX::InjectComponent does what I need.

      I have two applications sharing quite a lot of codebase (they are actually two interfaces to one backend). They have many common actions, they use same DBIx::Class::Model, they both render their output via Mason with same configuration.

      Of course I could create OurApp::Controller::* and inherited it by MyApp::Controller::* and YourApp::Controller::*, but it just triples the number of files.

        In that case I'd work on putting together an API layer over the backend and having the web apps just be layers on top of THAT that use those API calls as opposed to injecting this with that and such. It will give you a tremendously more flexible application structure.

        mtfnpy

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://893805]
Approved by stonecolddevin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found