From: Brian Cassidy Date: Fri, 30 May 2008 13:25:38 +0000 (+0000) Subject: minor change to warning. docs + Changes X-Git-Tag: 5.7099_04~61 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=cbc45ac74f083510f658537fbcc695762ac4531a minor change to warning. docs + Changes --- diff --git a/Changes b/Changes index b826322..1d2fa75 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,14 @@ # This file documents the revision history for Perl extension Catalyst. 5.7xxx xxx + - Refactored component resolution (component(), models(), model(), et al). We now + throw warnings for two reasons: + 1) model() or view() was called with no arguments, and two results are returned + -- set default_(model|view), current_(model|view) or current_(model|view)_instance + instead + 2) you call a component resolution method with a string, and it resorts to a regexp + fallback wherein a result is returned -- if you really want to search, call the + method with a regex as the argument - Get some of the optional_* tests working from dirs with spaces (RT #26455) - Fix Catalyst::Utils::home() when application .pm is in the current dir (RT #34437) diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 83366f5..a75f43b 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -441,8 +441,8 @@ sub _comp_search_prefixes { # don't warn if we didn't find any results, it just might not exist if( @result ) { - $c->log->warn( 'Relying on the regexp fallback behavior for component resolution' ); - $c->log->warn( 'is unreliable and unsafe. You have been warned' ); + $c->log->warn( 'Relying on the regexp fallback behavior for component resolution is unreliable and unsafe.' ); + $c->log->warn( 'If you really want to search, pass in a regexp as the argument.' ); } return @result; @@ -481,6 +481,12 @@ Gets a L instance by name. If the name is omitted, will return the controller for the dispatched action. +If you want to search for controllers, pass in a regexp as the argument. + + # find all controllers that start with Foo + my @foo_controllers = $c->controller(qr{^Foo}); + + =cut sub controller { @@ -509,6 +515,11 @@ If the name is omitted, it will look for - a config setting 'default_model', or - check if there is only one model, and return it if that's the case. +If you want to search for models, pass in a regexp as the argument. + + # find all models that start with Foo + my @foo_models = $c->model(qr{^Foo}); + =cut sub model { @@ -557,6 +568,11 @@ If the name is omitted, it will look for - a config setting 'default_view', or - check if there is only one view, and return it if that's the case. +If you want to search for views, pass in a regexp as the argument. + + # find all views that start with Foo + my @foo_views = $c->view(qr{^Foo}); + =cut sub view { @@ -633,6 +649,9 @@ unless you want to get a specific component by full class. C<< $c->controller >>, C<< $c->model >>, and C<< $c->view >> should be used instead. +If C<$name> is a regexp, a list of components matched against the full +component name will be returned. + =cut sub component {