[Catalyst-commits] r10600 - in
Catalyst-Runtime/5.80/branches/index_default_fuckage:
lib/Catalyst lib/Catalyst/DispatchType t/aggregate t/lib
t/lib/TestAppIndexActionName/Controller
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Fri Jun 19 23:47:02 GMT 2009
Author: caelum
Date: 2009-06-19 23:47:02 +0000 (Fri, 19 Jun 2009)
New Revision: 10600
Added:
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_named_index.t
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName.pm
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName/
Removed:
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_index_or_default_names.t
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault.pm
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault/
Modified:
Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/DispatchType/Index.pm
Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/Dispatcher.pm
Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName/Controller/IndexChained.pm
Log:
prevent actions named index from registering as an index dispatchtype if they can be registered with another dispatchtype
Modified: Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/DispatchType/Index.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/DispatchType/Index.pm 2009-06-19 20:46:45 UTC (rev 10599)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/DispatchType/Index.pm 2009-06-19 23:47:02 UTC (rev 10600)
@@ -2,7 +2,7 @@
use Moose;
extends 'Catalyst::DispatchType';
-no Moose;
+use namespace::clean -except => 'meta';
=head1 NAME
@@ -25,6 +25,12 @@
=back
+=cut
+
+has _actions => (
+ is => 'rw', isa => 'HashRef', default => sub { +{} }
+);
+
=head1 METHODS
=head2 $self->match( $c, $path )
@@ -40,6 +46,8 @@
return if @{ $c->req->args };
my $result = $c->get_action( 'index', $path );
+ return 0 unless $result && exists $self->_actions->{ $result->reverse };
+
if ($result && $result->match($c)) {
$c->action($result);
$c->namespace( $result->namespace );
@@ -50,6 +58,20 @@
return 0;
}
+=head2 $self->register( $c, $action )
+
+Register an action with this DispatchType.
+
+=cut
+
+sub register {
+ my ( $self, $c, $action ) = @_;
+
+ $self->_actions->{ $action->reverse } = $action;
+
+ return 1;
+}
+
=head2 $self->uri_for_action( $action, $captures )
get a URI part for an action; always returns undef is $captures is set
Modified: Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/Dispatcher.pm 2009-06-19 20:46:45 UTC (rev 10599)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/lib/Catalyst/Dispatcher.pm 2009-06-19 23:47:02 UTC (rev 10600)
@@ -531,11 +531,31 @@
}
}
+ my @dtypes = @{ $self->_dispatch_types };
+ my @normal_dtypes;
+ my @low_precedence_dtypes;
+
+ while (my $type = shift @dtypes) {
+ if ($type->isa('Catalyst::DispatchType::Index') ||
+ $type->isa('Catalyst::DispatchType::Default')) {
+ push @low_precedence_dtypes, $type;
+ } else {
+ push @normal_dtypes, $type;
+ }
+ }
+
# Pass the action to our dispatch types so they can register it if reqd.
- foreach my $type ( @{ $self->_dispatch_types } ) {
- $type->register( $c, $action );
+ my $was_registered = 0;
+ foreach my $type ( @normal_dtypes ) {
+ $was_registered = 1 if $type->register( $c, $action );
}
+ if (not $was_registered) {
+ foreach my $type ( @low_precedence_dtypes ) {
+ $type->register( $c, $action );
+ }
+ }
+
my $namespace = $action->namespace;
my $name = $action->name;
Deleted: Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_index_or_default_names.t
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_index_or_default_names.t 2009-06-19 20:46:45 UTC (rev 10599)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_index_or_default_names.t 2009-06-19 23:47:02 UTC (rev 10600)
@@ -1,29 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/../lib";
-
-our $iters;
-
-BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-
-use Test::More tests => 1*$iters;
-
-use Catalyst::Test 'TestAppIndexDefault';
-
-if ( $ENV{CAT_BENCHMARK} ) {
- require Benchmark;
- Benchmark::timethis( $iters, \&run_tests );
-}
-else {
- for ( 1 .. $iters ) {
- run_tests();
- }
-}
-
-sub run_tests {
- is(get('/indexchained'), 'index_chained', ':Chained overrides index');
-}
Copied: Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_named_index.t (from rev 10586, Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_index_or_default_names.t)
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_named_index.t (rev 0)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/t/aggregate/live_component_controller_action_named_index.t 2009-06-19 23:47:02 UTC (rev 10600)
@@ -0,0 +1,29 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+our $iters;
+
+BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
+
+use Test::More tests => 1*$iters;
+
+use Catalyst::Test 'TestAppIndexActionName';
+
+if ( $ENV{CAT_BENCHMARK} ) {
+ require Benchmark;
+ Benchmark::timethis( $iters, \&run_tests );
+}
+else {
+ for ( 1 .. $iters ) {
+ run_tests();
+ }
+}
+
+sub run_tests {
+ is(get('/indexchained'), 'index_chained', ':Chained overrides index');
+}
Copied: Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName (from rev 10586, Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault)
Modified: Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName/Controller/IndexChained.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault/Controller/IndexChained.pm 2009-06-18 21:38:40 UTC (rev 10586)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName/Controller/IndexChained.pm 2009-06-19 23:47:02 UTC (rev 10600)
@@ -1,4 +1,4 @@
-package TestAppIndexDefault::Controller::IndexChained;
+package TestAppIndexActionName::Controller::IndexChained;
use base 'Catalyst::Controller';
Copied: Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName.pm (from rev 10586, Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault.pm)
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName.pm (rev 0)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexActionName.pm 2009-06-19 23:47:02 UTC (rev 10600)
@@ -0,0 +1,8 @@
+package TestAppIndexActionName;
+use strict;
+use warnings;
+use Catalyst;
+
+__PACKAGE__->setup;
+
+1;
Deleted: Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault.pm 2009-06-19 20:46:45 UTC (rev 10599)
+++ Catalyst-Runtime/5.80/branches/index_default_fuckage/t/lib/TestAppIndexDefault.pm 2009-06-19 23:47:02 UTC (rev 10600)
@@ -1,8 +0,0 @@
-package TestAppIndexDefault;
-use strict;
-use warnings;
-use Catalyst;
-
-__PACKAGE__->setup;
-
-1;
More information about the Catalyst-commits
mailing list