X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=bed30ee274fab24510b0b8999c32e3a712632c38;hb=75aff34de50f286204ccee4b293e761c90243b4e;hp=83366f52edbe7e89e0f48aa8c36e708d0f51e7ca;hpb=c49b3de44e34e737e058fc6837719dd9d437edbd;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 83366f5..bed30ee 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -49,6 +49,7 @@ our $COUNT = 1; our $START = time; our $RECURSION = 1000; our $DETACH = "catalyst_detach\n"; +our $GO = "catalyst_go\n"; __PACKAGE__->mk_classdata($_) for qw/components arguments dispatcher engine log dispatcher_class @@ -63,7 +64,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.7014'; +our $VERSION = '5.7099_02'; sub import { my ( $class, @arguments ) = @_; @@ -327,6 +328,20 @@ When called with no arguments it escapes the processing chain entirely. sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) } +=head2 $c->go( $action [, \@arguments ] ) + +=head2 $c->go( $class, $method, [, \@arguments ] ) + +Almost the same as C, but does a full dispatch, instead of just +calling the new C<$action> / C<$class-E$method>. This means that C, +C and the method you go to is called, just like a new request. + +C<$c-Estash> is kept unchanged. + +=cut + +sub go { my $c = shift; $c->dispatcher->go( $c, @_ ) } + =head2 $c->response =head2 $c->res @@ -437,12 +452,17 @@ 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( '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 +501,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 { @@ -504,11 +530,16 @@ Gets a L instance by name. Any extra arguments are directly passed to ACCEPT_CONTEXT. If the name is omitted, it will look for - - a model object in $c->stash{current_model_instance}, then + - a model object in $c->stash->{current_model_instance}, then - a model name in $c->stash->{current_model}, then - 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 { @@ -552,11 +583,16 @@ Gets a L instance by name. Any extra arguments are directly passed to ACCEPT_CONTEXT. If the name is omitted, it will look for - - a view object in $c->stash{current_view_instance}, then + - a view object in $c->stash->{current_view_instance}, then - a view name in $c->stash->{current_view}, then - 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 +669,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 { @@ -1241,7 +1280,12 @@ sub execute { my $last = pop( @{ $c->stack } ); if ( my $error = $@ ) { - if ( !ref($error) and $error eq $DETACH ) { die $DETACH if $c->depth > 1 } + if ( !ref($error) and $error eq $DETACH ) { + die $DETACH if($c->depth > 1); + } + elsif ( !ref($error) and $error eq $GO ) { + die $GO if($c->depth > 0); + } else { unless ( ref $error ) { no warnings 'uninitialized'; @@ -1867,6 +1911,11 @@ search paths, specify a key named C as an array reference. Items in the array beginning with C<::> will have the application class name prepended to them. +All components found will also have any +L loaded and set up as components. +Note, that modules which are B an I of the main +file namespace loaded will not be instantiated as components. + =cut sub setup_components { @@ -2372,13 +2421,15 @@ Wiki: =head2 L - The test suite. -=head1 CREDITS +=head1 PROJECT FOUNDER + +sri: Sebastian Riedel -Andy Grundman +=head1 CONTRIBUTORS -Andy Wardley +abw: Andy Wardley -Andreas Marienborg +acme: Leon Brocard Andrew Bramble @@ -2386,65 +2437,67 @@ Andrew Ford Andrew Ruthven -Arthur Bergman +andyg: Andy Grundman -Autrijus Tang +audreyt: Audrey Tang -Brian Cassidy +bricas: Brian Cassidy -Carl Franks +chansen: Christian Hansen -Christian Hansen +chicks: Christopher Hicks -Christopher Hicks +dkubb: Dan Kubb -Dan Sully +Drew Taylor -Danijel Milicevic +esskar: Sascha Kiefer -David Kamholz +fireartist: Carl Franks -David Naughton - -Drew Taylor +gabb: Danijel Milicevic Gary Ashton Jones Geoff Richards -Jesse Sheidlower - -Jesse Vincent +jcamacho: Juan Camacho Jody Belka Johan Lindstrom -Juan Camacho +jon: Jon Schutz -Leon Brocard +marcus: Marcus Ramberg -Marcus Ramberg +miyagawa: Tatsuhiko Miyagawa -Matt S Trout +mst: Matt S. Trout -Robert Sedlacek +mugwump: Sam Vilain -Sam Vilain +naughton: David Naughton -Sascha Kiefer +ningu: David Kamholz -Sebastian Willert +nothingmuch: Yuval Kogman -Tatsuhiko Miyagawa +numa: Dan Sully -Ulf Edvinsson +obra: Jesse Vincent + +omega: Andreas Marienborg -Yuval Kogman +phaylon: Robert Sedlacek -=head1 AUTHOR +sky: Arthur Bergman + +the_jester: Jesse Sheidlower + +Ulf Edvinsson -Sebastian Riedel, C +willert: Sebastian Willert =head1 LICENSE