X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=733e1eac9054c10958e282d4c34b06d8130022b4;hb=f6e054bb531b18cbe6c7826efdbf804a87e4858f;hp=f1c473bd11f4e760dbb1514212a2f49d6852ee12;hpb=0f7ecc537d7a258023b1a58311f197ad5dca24c7;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index f1c473b..733e1ea 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -388,6 +388,7 @@ Get an action in a given namespace. sub get_action { my ( $c, $action, $namespace ) = @_; + return [] unless $action; $namespace ||= ''; if ($namespace) { $namespace = '' if $namespace eq '/'; @@ -459,10 +460,13 @@ sub handler { for my $begin ( @{ $c->get_action( 'begin', $namespace ) } ) { $c->state( $c->execute( @{ $begin->[0] } ) ); } - for my $result ( @{ $c->get_action( $action, $default ) }[-1] ) - { - $c->state( $c->execute( @{ $result->[0] } ) ); - last unless $default; + if ( my $action = $c->req->action ) { + for my $result ( + @{ $c->get_action( $action, $default ) }[-1] ) + { + $c->state( $c->execute( @{ $result->[0] } ) ); + last unless $default; + } } for my $end ( reverse @{ $c->get_action( 'end', $namespace ) } ) { @@ -486,6 +490,9 @@ sub handler { my $av = sprintf '%.3f', 1 / $elapsed; my $t = Text::ASCIITable->new; $t->setCols( 'Action', 'Time' ); + $t->setColWidth( 'Action', 64, 1 ); + $t->setColWidth( 'Time', 9, 1 ); + for my $stat (@stats) { $t->addRow(@$stat); } @@ -531,9 +538,9 @@ sub prepare { if ( $c->debug ) { my $secs = time - $START || 1; my $av = sprintf '%.3f', $COUNT / $secs; - $c->log->debug('********************************'); + $c->log->debug('**********************************'); $c->log->debug("* Request $COUNT ($av/s) [$$]"); - $c->log->debug('********************************'); + $c->log->debug('**********************************'); $c->res->headers->header( 'X-Catalyst' => $Catalyst::VERSION ); } $c->prepare_request($r); @@ -553,6 +560,8 @@ sub prepare { if ( $c->debug && keys %{ $c->req->params } ) { my $t = Text::ASCIITable->new; $t->setCols( 'Key', 'Value' ); + $t->setColWidth( 'Key', 37, 1 ); + $t->setColWidth( 'Value', 36, 1 ); for my $key ( keys %{ $c->req->params } ) { my $value = $c->req->params->{$key} || ''; $t->addRow( $key, $value ); @@ -582,7 +591,8 @@ sub prepare_action { if ($#$result) { my $match = $result->[1]; my @snippets = @{ $result->[2] }; - $c->log->debug(qq/Requested action "$path" matched "$match"/) + $c->log->debug( + qq/Requested action is "$path" and matched "$match"/) if $c->debug; $c->log->debug( 'Snippets are "' . join( ' ', @snippets ) . '"' ) @@ -592,7 +602,7 @@ sub prepare_action { } else { $c->req->action($path); - $c->log->debug(qq/Requested action "$path"/) if $c->debug; + $c->log->debug(qq/Requested action is "$path"/) if $c->debug; } $c->req->match($path); last; @@ -853,12 +863,16 @@ sub setup_components { } my $t = Text::ASCIITable->new; $t->setCols('Class'); + $t->setColWidth( 'Class', 75, 1 ); $t->addRow($_) for keys %{ $self->components }; $self->log->debug( 'Loaded components', $t->draw ) if ( @{ $t->{tbl_rows} } && $self->debug ); my $actions = $self->actions; my $privates = Text::ASCIITable->new; $privates->setCols( 'Action', 'Class', 'Code' ); + $privates->setColWidth( 'Action', 28, 1 ); + $privates->setColWidth( 'Class', 28, 1 ); + $privates->setColWidth( 'Code', 14, 1 ); my $walker = sub { my ( $walker, $parent, $prefix ) = @_; $prefix .= $parent->getNodeValue || ''; @@ -875,6 +889,10 @@ sub setup_components { if ( @{ $privates->{tbl_rows} } && $self->debug ); my $publics = Text::ASCIITable->new; $publics->setCols( 'Action', 'Class', 'Code' ); + $publics->setColWidth( 'Action', 28, 1 ); + $publics->setColWidth( 'Class', 28, 1 ); + $publics->setColWidth( 'Code', 14, 1 ); + for my $plain ( sort keys %{ $actions->{plain} } ) { my ( $class, $code ) = @{ $actions->{plain}->{$plain} }; $publics->addRow( "/$plain", $class, $code ); @@ -883,6 +901,9 @@ sub setup_components { if ( @{ $publics->{tbl_rows} } && $self->debug ); my $regexes = Text::ASCIITable->new; $regexes->setCols( 'Action', 'Class', 'Code' ); + $regexes->setColWidth( 'Action', 28, 1 ); + $regexes->setColWidth( 'Class', 28, 1 ); + $regexes->setColWidth( 'Code', 14, 1 ); for my $regex ( sort keys %{ $actions->{regex} } ) { my ( $class, $code ) = @{ $actions->{regex}->{$regex} }; $regexes->addRow( $regex, $class, $code ); @@ -928,24 +949,6 @@ sub _class2prefix { return $prefix; } -sub _prettify_action { - my ( $val1, $val2, $val3 ) = @_; - formline ' + @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<' - . ' @>>>>>>>>>>>>>> ', $val1, $val2, $val3; - my $formatted = $^A; - $^A = ''; - return $formatted; -} - -sub _prettify_stats { - my ( $val1, $val2 ) = @_; - formline ' + @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ', - $val1, $val2; - my $formatted = $^A; - $^A = ''; - return $formatted; -} - =back =head1 AUTHOR