[Catalyst] Catalyst configuration problem with more than one mod_perl configuration

Albert Vila avp at imente.com
Wed Mar 8 18:13:42 CET 2006

I'm having trouble with the Catalyst configuration under mod_perl,  
but only if I have more than one catalyst application in the same  

I'm using an extra module to deal with configurations, because I need  
to load more configuration files in the same catalyst application.

My configuration object looks like:

package Util::Config;

# Object
my $object = undef;

# Init base configuration
sub init_base {
	my ($self) = shift;
	return if (defined $object->{_FLAG_BASE_CONFIG});
	my $base_conf = 'Conf/base.yml';
	foreach my $lib (@INC) {
		if (-e ($lib.'/'.$base_conf)) {
			$base_conf = $lib.'/'.$base_conf;
	# Load base configuration
	use YAML 'LoadFile';
	my $base_options = LoadFile($base_conf);

	# Flag
	$object->{_FLAG_BASE_CONFIG} = 1;
	# Inicialitzem la configuració base de l'aplicació

# Init configuration
sub init {
   my ($self, $file) = (@_);

   # Init base configuration

   # Init catalyst configuration
   if (ref($file) eq 'HASH') {
   	foreach my $key (keys %{$file}) {
		$object->{$key} = $file->{$key};

# Gets the configuration entry
sub get {
	my ($self, $key) = (@_);
	return $object->{$key};


I use the object this way inside the catalyst application:

__PACKAGE__->config( 'config_file' => 'conf/X.yml' );
Util::Config->init( __PACKAGE__->config );

and then I get the values using Util::Config->get('xxxx').

When I only load the X application with mod_perl all works fine, but  
If I load the X and the Y application, the configuration get mess.

For example (I assume the X application loads first with mod_perl),  
then in the Y application:

use Catalyst;

__PACKAGE__->config( 'config_file' => 'conf/Y.yml' );
Util::Config->init( __PACKAGE__->config );
[1] die Util::Config->get('root')."-".__PACKAGE__->config->{root};

sub begin {
	my ($self, $c) = @_;

	[2] die Util::Config->get('root')."-".$c->config->{root};


In this scenario, I get the following results:

[1]-> /path/Y - /path/Y

but in

[2]-> /path/X - /path/Y

Anyone has a clue why in the second log i get the X root path using  
the Util::Config object?

Thanks if anyone can help. I'll apreciate.


More information about the Catalyst mailing list