X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=effe8277c4456c2da7d5d57a2b4514f7f73525ac;hb=refs%2Fheads%2Fjnap%2Fcontroller_init;hp=820eaed14673bb7d03e3e3e56dd6d410a6633578;hpb=75ce30d0f208d49ead0134ab45fc2f45f72d6023;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 820eaed..effe827 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -143,17 +143,27 @@ sub _BEGIN : Private { my $begin = ( $c->get_actions( 'begin', $c->namespace ) )[-1]; return 1 unless $begin; $begin->dispatch( $c ); - return !@{ $c->error }; + #If there is an error, all bets off + if( @{ $c->error }) { + return !@{ $c->error }; + } else { + return $c->state || 1; + } } sub _AUTO : Private { my ( $self, $c ) = @_; my @auto = $c->get_actions( 'auto', $c->namespace ); foreach my $auto (@auto) { + # We FORCE the auto action user to explicitly return + # true. We need to do this since there's some auto + # users (Catalyst::Authentication::Credential::HTTP) that + # actually do a detach instead. + $c->state(0); $auto->dispatch( $c ); return 0 unless $c->state; } - return 1; + return $c->state || 1; } sub _ACTION : Private { @@ -164,7 +174,12 @@ sub _ACTION : Private { { $c->action->dispatch( $c ); } - return !@{ $c->error }; + #If there is an error, all bets off + if( @{ $c->error }) { + return !@{ $c->error }; + } else { + return $c->state || 1; + } } sub _END : Private { @@ -204,7 +219,18 @@ around action_namespace => sub { $case_s = $class->config->{case_sensitive}; } else { if (ref $self) { - $case_s = ref($self->_application)->config->{case_sensitive}; + # This seems like total wack from 2009. Not sure + # why we'd take a ref on _application since we + # expect it to be a string... Seems like it was + # part of a whole bunch of changes related to the + # failed app/ctx stuff from years ago. However + # in cases where the controller gets called in + # application context, this now fails hard. I've + # added defensive 'if its a ref' code just to be + # safe but I don't think its really ever used + my $local_app = ref($self->_application) ? + ref($self->_application): $self->_application; + $case_s = $local_app->config->{case_sensitive}; } else { confess("Can't figure out case_sensitive setting"); } @@ -389,7 +415,7 @@ sub _parse_attrs { # Parse out :Foo(bar) into Foo => bar etc (and arrayify) - if ( my ( $key, $value ) = ( $attr =~ /^(.*?)(?:\(\s*(.+?)\s*\))?$/ ) ) + if ( my ( $key, $value ) = ( $attr =~ /^(.*?)(?:\(\s*(.+?)?\s*\))?$/ ) ) { if ( defined $value ) { @@ -898,6 +924,15 @@ declared attributes you must quote them: sub my_moose_type :Local Args('Int') { ... } +If you use 'reference' type constraints (such as ArrayRef[Int]) that have an unknown +number of allowed matches, we set this the same way "Args" is. Please keep in mind +that actions with an undetermined number of args match at lower precedence than those +with a fixed number. You may use reference types such as Tuple from L +that allows you to fix the number of allowed args. For example Args(Tuple[Int,Int]) +would be determined to be two args (or really the same as Args(Int,Int).) You may +find this useful for creating custom subtypes with complex matching rules that you +wish to reuse over many actions. + See L for more. =head2 Consumes('...')