[Catalyst-commits] r13626 - in Catalyst-Runtime/5.80/trunk: . lib
t/aggregate t/lib t/lib/TestAppViewWarnings
t/lib/TestAppViewWarnings/Controller
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Sep 29 01:34:03 GMT 2010
Author: t0m
Date: 2010-09-29 02:34:03 +0100 (Wed, 29 Sep 2010)
New Revision: 13626
Added:
Catalyst-Runtime/5.80/trunk/t/aggregate/live_view_warnings.t
Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings.pm
Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings/
Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings/Controller/
Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings/Controller/Root.pm
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Log:
Patch from the mailing list to clarify view warning
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2010-09-29 01:02:43 UTC (rev 13625)
+++ Catalyst-Runtime/5.80/trunk/Changes 2010-09-29 01:34:03 UTC (rev 13626)
@@ -1,5 +1,9 @@
# This file documents the revision history for Perl extension Catalyst.
+ - Add a warning when $c->view is called and cannot locate a default_view
+ or current_view. This clarifies the logging when ::RenderView gets
+ confused.
+
- Deal with Moose >= 1.15 warning if you add a method called 'meta' to a
class which already has one by using _add_meta_method.
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2010-09-29 01:02:43 UTC (rev 13625)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2010-09-29 01:34:03 UTC (rev 13626)
@@ -750,7 +750,12 @@
unless ( ref($name) ) { # Direct component hash lookup to avoid costly regexps
my $comps = $c->components;
my $check = $appclass."::View::".$name;
- return $c->_filter_component( $comps->{$check}, @args ) if exists $comps->{$check};
+ if( exists $comps->{$check} ) {
+ return $c->_filter_component( $comps->{$check}, @args );
+ }
+ else {
+ $c->log->warn( "Attempted to use view '$check', but does not exist" );
+ }
}
my @result = $c->_comp_search_prefixes( $name, qw/View V/ );
return map { $c->_filter_component( $_, @args ) } @result if ref $name;
Added: Catalyst-Runtime/5.80/trunk/t/aggregate/live_view_warnings.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_view_warnings.t (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_view_warnings.t 2010-09-29 01:34:03 UTC (rev 13626)
@@ -0,0 +1,23 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+use Test::More;
+use Catalyst::Test 'TestAppViewWarnings';
+
+if ( $ENV{CATALYST_SERVER} ) {
+ plan skip_all => 'Using remote server';
+}
+
+{
+ ok( my $response = request('http://localhost/'), 'Request' );
+ like($TestAppViewWarnings::log_messages[0], qr/Attempted to use view/s, 'View failure warning received');
+
+}
+
+done_testing;
+
Added: Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings/Controller/Root.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings/Controller/Root.pm 2010-09-29 01:34:03 UTC (rev 13626)
@@ -0,0 +1,17 @@
+package TestAppViewWarnings::Controller::Root;
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config->{namespace} = '';
+
+# Return log messages from previous request
+sub index :Path Args() {}
+
+sub end : Action {
+ my ($self, $c) = @_;
+ $c->view; # Cause view lookup and ergo warning we are testing.
+ $c->res->body('foo');
+}
+
+1;
Added: Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestAppViewWarnings.pm 2010-09-29 01:34:03 UTC (rev 13626)
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+
+package TestAppViewWarnings;
+
+use Catalyst;
+
+our @log_messages;
+
+__PACKAGE__->config( name => 'TestAppWarnings', root => '/some/dir', default_view => "DoesNotExist" );
+
+__PACKAGE__->log(TestAppViewWarnings::Log->new);
+
+__PACKAGE__->setup;
+
+package TestAppViewWarnings::Log;
+
+use base qw/Catalyst::Log/;
+sub warn { push(@TestAppViewWarnings::log_messages, @_[1..$#_]); }
+
+1;
+
More information about the Catalyst-commits
mailing list