X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=b06f6467a768e700c8bd9ec5d2e46c0478bfaef1;hb=250cad0f65cf92f1a48dcbd7db4952970563a3c2;hp=c20ceca6b417f2ef27aae2a55d5d02f655f49071;hpb=15f1c98d0d0887ed21889f4f392afc6e536b19d5;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index c20ceca..b06f646 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -64,7 +64,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.7099_02'; +our $VERSION = '5.7099_03'; sub import { my ( $class, @arguments ) = @_; @@ -98,7 +98,7 @@ documentation and tutorials. catalyst.pl MyApp # add models, views, controllers - script/myapp_create.pl model MyDatabase DBIC::Schema create=dynamic dbi:SQLite:/path/to/db + script/myapp_create.pl model MyDatabase DBIC::Schema create=static dbi:SQLite:/path/to/db script/myapp_create.pl view MyTemplate TT script/myapp_create.pl controller Search @@ -452,10 +452,16 @@ sub _comp_search_prefixes { # regexp fallback $query = qr/$name/i; - @result = grep { $eligible{ $_ } =~ m{$query} } keys %eligible; + @result = map { $c->components->{ $_ } } grep { $eligible{ $_ } =~ m{$query} } keys %eligible; + + # no results? try against full names + if( !@result ) { + @result = map { $c->components->{ $_ } } grep { m{$query} } keys %eligible; + } # don't warn if we didn't find any results, it just might not exist if( @result ) { + $c->log->warn( qq(Found results for "${name}" using regexp fallback.) ); $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.' ); } @@ -677,11 +683,13 @@ sub component { if( !ref $name ) { # is it the exact name? - return $comps->{ $name } if exists $comps->{ $name }; + return $c->_filter_component( $comps->{ $name }, @args ) + if exists $comps->{ $name }; # perhaps we just omitted "MyApp"? my $composed = ( ref $c || $c ) . "::${name}"; - return $comps->{ $composed } if exists $comps->{ $composed }; + return $c->_filter_component( $comps->{ $composed }, @args ) + if exists $comps->{ $composed }; # search all of the models, views and controllers my( $comp ) = $c->_comp_search_prefixes( $name, qw/Model M Controller C View V/ ); @@ -692,12 +700,13 @@ sub component { my $query = ref $name ? $name : qr{$name}i; my @result = grep { m{$query} } keys %{ $c->components }; - return @result if ref $name; + return map { $c->_filter_component( $_, @args ) } @result if ref $name; if( $result[ 0 ] ) { + $c->log->warn( qq(Found results for "${name}" using regexp fallback.) ); $c->log->warn( 'Relying on the regexp fallback behavior for component resolution' ); $c->log->warn( 'is unreliable and unsafe. You have been warned' ); - return $result[ 0 ]; + return $c->_filter_component( $result[ 0 ], @args ); } # I would expect to return an empty list here, but that breaks back-compat