tags:

views:

95

answers:

3

I am planning a Catalyst application, that will be deployed over a number of servers. It will be used internally by support staff to control aspects of an operational system that runs on those servers.

The application will run much in the same way on each server, save for a limited amount of site specific behaviours. Some actions will only apply to some servers, and some actions will behave differently on other servers.

Are there any recognized design patterns/practices that enable site-specific customization of a Catalyst application?

I am currently thinking of deploying a site configuration file alongside the application, that will be used to determine what actions to enable, and set parameters that control other action's behaviour. Ideally this customization would happen when the application is loaded by mod_perl (Apache2) - but I am not sure if that would even be possible.

Any suggestions welcome!

A: 

You can set templates, or have conditional behaviour in the controllers based on the value of $c->req->host.

singingfish
+4  A: 

Catalyst::Plugin::ConfigLoader has code to help you with site-specific configuration in the form of the MYAPP_CONFIG_LOCAL_SUFFIX environment variable. Since Controllers are Components and config is available at setup_components time, you can do whatever foolery you want with action registration when your controller is compiled. There's not much pre-rolled for it, because everyone's requirements are so different, but it's not exceptionally hard, and there's advice to be found on the mailing list.

hobbs
That sounds close to what I want. To give a more concrete example, I want to set the root view template during compile time, rather than having an if-test in my controller actions. I will have to read up on setup_components by the sounds of it.
megamic
A: 

I always use the unique combination of $HOSTNAME and $USER to define the specific configuration file to be loaded, e.g.

conf => "my_app_${hostname}_${user}.conf"
Kiffin
That's an interesting idea I had not considered, thanks.
megamic