[Catalyst-commits] r9658 - in trunk/Catalyst-Plugin-Cache: .
lib/Catalyst/Plugin
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sat Apr 4 05:01:29 GMT 2009
Author: t0m
Date: 2009-04-04 06:01:28 +0100 (Sat, 04 Apr 2009)
New Revision: 9658
Modified:
trunk/Catalyst-Plugin-Cache/Changes
trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm
Log:
Warn if you use old config key or blank config. There is a load of simplification that can happen here I think, as there is still compat for Plugin::Cache::FastMMap, which is dead as a doornail. Also needs better docs
Modified: trunk/Catalyst-Plugin-Cache/Changes
===================================================================
--- trunk/Catalyst-Plugin-Cache/Changes 2009-04-03 22:00:51 UTC (rev 9657)
+++ trunk/Catalyst-Plugin-Cache/Changes 2009-04-04 05:01:28 UTC (rev 9658)
@@ -1,3 +1,5 @@
+ - Generate a warning if no config is specified, or config
+ is specified using the old key.
0.08
- Forgot to add MRO::Compat to Makefile.PL, fail.
Modified: trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm
===================================================================
--- trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm 2009-04-03 22:00:51 UTC (rev 9657)
+++ trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm 2009-04-04 05:01:28 UTC (rev 9658)
@@ -31,10 +31,23 @@
$ret;
}
-
-sub _get_cache_plugin_config {
- my ($app) = @_;
- return $app->config->{'Plugin::Cache'} || $app->config->{cache};
+{
+ my %has_warned_for;
+ sub _get_cache_plugin_config {
+ my ($app) = @_;
+ my $config = $app->config->{'Plugin::Cache'};
+ if (!$config) {
+ $config = $app->config->{cache};
+ my $appname = ref($app);
+ if (! $has_warned_for{$appname}++ ) {
+ $app->log->warn($config ?
+ 'Catalyst::Plugin::Cache config found in deprecated $c->config->{cache}, please move to $c->config->{"Plugin::Cache"}.'
+ : 'Catalyst::Plugin::Cache config not found, using empty config!'
+ );
+ }
+ }
+ return $config || {};
+ }
}
sub get_default_cache_backend_config {
@@ -54,7 +67,7 @@
$app->maybe::next::method;
# FIXME - Don't know why the _get_cache_plugin_config method doesn't work here!
- my $conf = $app->config->{'Plugin::Cache'} ? $app->config->{'Plugin::Cache'}->{backends} : $app->config->{cache}->{backends};
+ my $conf = $app->_get_cache_plugin_config->{backends};
foreach my $name ( keys %$conf ) {
next if $app->get_cache_backend( $name );
$app->setup_generic_cache_backend( $name, $app->get_cache_backend_config( $name ) || {} );
More information about the Catalyst-commits
mailing list