[Catalyst] Strange dispatcher code
Keith Grennan
keith at squeegeemedia.com
Tue May 3 11:27:13 CEST 2005
Hello,
I can't seem to make execution stop by returning zero from my "auto"
action. Looking at the dispatcher code I can't make sense of what it's
supposed to do:
my $auto = 0;
for my $auto ( @{ $c->get_action( 'auto', $namespace ) } ) {
$c->execute( @{ $auto->[0] } );
return if scalar @{ $c->error };
last unless $c->state;
$auto++;
}
$auto looks like it's being used both as an counter and as an iterator.
further down we have this:
# Execute the action or last default
my $mkay = $auto ? $c->state ? 1 : 0 : 1;
if ( ( my $action = $c->req->action ) && $mkay ) {
if ( my $result = @{ $c->get_action( $action, $default ) }[-1] ) {
$c->execute( @{ $result->[0] } );
}
}
this looks a bit fishy to me too. if I have a single "auto" action,
which returns zero, $auto will not get incremented (because of 'last
unless $c->state' above). so $mkay will be set to 1, and the action
will still be executed.
it looks to me like the "$auto" counter should be renamed, and '$auto++'
should go before 'last unless $c->state'.
thanks!
keith
More information about the Catalyst
mailing list