From: Sebastian Riedel Date: Fri, 2 Dec 2005 01:55:51 +0000 (+0000) Subject: Fixed Path and index actions in the appclass X-Git-Tag: 5.7099_04~803 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=61a9002d77ce79bc038b3ec6212e275015801594 Fixed Path and index actions in the appclass --- diff --git a/Changes b/Changes index 34e247e..db71005 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ This file documents the revision history for Perl extension Catalyst. 5.60 + - Fixed Path and index actions in the appclass, + including those that attach to / + - Index is now weighted higher than Path - Fixed restarter and -d debug switch in server.pl. - Added a warning if you attempt to retrieve a parameter using $c->req->params('foo'). diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 1672712..98ef303 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -25,7 +25,8 @@ sub list { my $paths = Text::SimpleTable->new( [ 36, 'Path' ], [ 37, 'Private' ] ); for my $path ( sort keys %{ $self->{paths} } ) { my $action = $self->{paths}->{$path}; - $paths->row( "/$path", "/$action" ); + $path = "/$path" unless $path eq '/'; + $paths->row( "$path", "/$action" ); } $c->log->debug( "Loaded Path actions:\n" . $paths->draw ) if ( keys %{ $self->{paths} } ); @@ -38,6 +39,7 @@ sub list { sub match { my ( $self, $c, $path ) = @_; + $path ||= '/'; if ( my $action = $self->{paths}->{$path} ) { $c->req->action($path); $c->req->match($path); @@ -62,7 +64,7 @@ sub register { foreach my $r ( @{ $attrs->{Path} || [] } ) { unless ($r) { $r = $action->namespace; - $r = '' if $r eq '/'; + $r = '/' unless $r; } elsif ( $r !~ m!^/! ) { # It's a relative path $r = $action->namespace . "/$r"; @@ -92,6 +94,7 @@ sub register { sub register_path { my ( $self, $c, $path, $action ) = @_; $path =~ s!^/!!; + $path = '/' unless $path; $self->{paths}{$path} = $action; } diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 4ceea4c..8c4a5d8 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -21,10 +21,10 @@ __PACKAGE__->mk_accessors( ); # Preload these action types -our @PRELOAD = qw/Path Regex/; +our @PRELOAD = qw/Index Path Regex/; # Postload these action types -our @POSTLOAD = qw/Index Default/; +our @POSTLOAD = qw/Default/; =head1 NAME @@ -178,12 +178,13 @@ sub prepare_action { my @path = split /\//, $c->req->path; $c->req->args( \my @args ); - push( @path, '/' ) unless @path; # Root action + unshift( @path, '' ); # Root action DESCEND: while (@path) { $path = join '/', @path; + $path =~ s#^/##; - $path = '' if $path eq '/'; # Root action + $path = '' if $path eq '/'; # Root action # Check out dispatch types to see if any will handle the path at # this level diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 2f78233..e8b1c86 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -448,7 +448,7 @@ controller it's in. C is much like C except that it takes no arguments and it is weighted slightly higher in the matching process. It is useful as a static entry point to a controller, e.g. to have a static -welcome page. +welcome page. Note that it's also weighted higher than Path. =item * B