[Catalyst-dev] Re: Patches for Catalyst::Plugin::ConfigLoader, Config::All and Config::All::General

Gareth Kirwan gbjk at thermeon.com
Wed Aug 22 13:08:38 GMT 2007


>* Brian Cassidy <brian.cassidy at nald.ca> [2007-08-22 04:25]:
>> Gareth Kirwan wrote:
>> >Patches and example config are here:
>> >
>> >http://scsys.co.uk:8001/8907
>> 
>> Crap. I haven't gotten to this yet, but your paste is gone
>

Sorry - I did append it inline for the email to Joel afterwards when I
realised that maybe the paste would expire.
( It hadn't, and at the time I considered scsys to be a permanent archive )

Below:

MyApp.pm
========
__PACKAGE__->config('Plugin::ConfigLoader' => {
        driver  => {
                General => {
                        -UseApacheInclude       => 1,
                        -IncludeRelative        => 1,
                        -IncludeDirectories     => 1,
                        }
                }
        });

Patches
=======

--- /usr/local/lib/perl5/site_perl/5.8.8/Catalyst/Plugin/ConfigLoader.pm
2007-08-08 13:16:41.
000000000 +0100
+++ ConfigLoader.pm     2007-08-08 15:26:23.000000000 +0100
@@ -51,7 +51,8 @@
     my $cfg   = Config::Any->load_files( {
         files   => \@files,
         filter  => \&_fix_syntax,
-        use_ext => 1
+        use_ext => 1,
+       loader_args     => $c->config->{'Plugin::ConfigLoader'}{driver}||{},
     } );

     # split the responses into normal and local cfg

--- /usr/local/lib/perl5/site_perl/5.8.8/Config/Any.pm  2007-02-26
01:14:08.000000000 +0000
+++ Any.pm      2007-08-08 15:36:25.000000000 +0100
@@ -85,7 +85,7 @@
     }

     my %load_args = map { $_ => defined $args->{$_} ? $args->{$_} : undef }
-        qw(filter use_ext force_plugins);
+        qw(filter use_ext force_plugins loader_args);
     $load_args{files} = [ grep { -f $_ } @{$args->{files}} ];
     return $class->_load(\%load_args);
 }
@@ -163,6 +163,9 @@
                last unless keys %files;
         my %ext = _maphash $loader->extensions;

+       my ($loader_class) = $loader =~ /::([^:]+)$/;
+       my $loader_args = $args->{loader_args}{$loader_class} || {};
+
         FILE:
         for my $filename (keys %files) {
             # use file extension to decide whether this loader should try
this file

--- /usr/local/lib/perl5/site_perl/5.8.8/Config/Any/General.pm  2006-08-22
22:35:28.000000000 +0100
+++ General.pm  2007-08-08 15:41:15.000000000 +0100
@@ -40,12 +40,17 @@
 sub load {
     my $class = shift;
     my $file  = shift;
+    my $args  = shift || {};

     # work around bug (?) in Config::General
 #   return if $class->_test_perl($file);

+    $args->{-ConfigFile} = $file;
+
+       use Data::Dumper;
+       warn Dumper($args);
     require Config::General;
-    my $configfile = Config::General->new( $file );
+    my $configfile = Config::General->new( %$args );
     my $config     = { $configfile->getall };
@@ -181,7 +184,7 @@

             my $config;
                        eval {
-                               $config = $loader->load( $filename );
+                               $config = $loader->load( $filename,
$loader_args );
                        };

                        next if $EVAL_ERROR; # if it croaked or warned, we
can't use it




More information about the Catalyst-dev mailing list