[Catalyst-commits] r8362 - in Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates: . lib lib/Catalyst lib/Catalyst/DispatchType t

marcus at dev.catalyst.perl.org marcus at dev.catalyst.perl.org
Sun Sep 7 14:04:19 BST 2008


Author: marcus
Date: 2008-09-07 14:04:19 +0100 (Sun, 07 Sep 2008)
New Revision: 8362

Removed:
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.rc
Modified:
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Changes
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Makefile.PL
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst.pm
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType.pm
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType/Chained.pm
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/Dispatcher.pm
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/ROADMAP.pod
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.t
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_component.t
   Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_mvc.t
Log:
 r26476 at Command-Central (orig r8329):  zarquon | 2008-09-02 14:01:11 +0200
  r13852 at zaphod:  kd | 2008-09-02 12:52:50 +0100
  rafl doc improvements
 
 r26477 at Command-Central (orig r8330):  zarquon | 2008-09-02 14:04:57 +0200
  r13854 at zaphod:  kd | 2008-09-02 13:04:40 +0100
  rafl's doc improvements in 5.8
 
 r26481 at Command-Central (orig r8334):  groditi | 2008-09-03 01:54:43 +0200
 only call ACCEPT_CONTEXT if we actually have a context
 r26484 at Command-Central (orig r8337):  rafl | 2008-09-03 08:03:36 +0200
 Fix ACCEPT_COMPONENT tests.
 
 As of r8334 MyApp->component doesn't invoke ACCEPT_COMPONENT anymore.
 r26485 at Command-Central (orig r8338):  rafl | 2008-09-03 08:03:41 +0200
 Test MyApp->component not invoking ACCEPT_CONTEXT.
 r26487 at Command-Central (orig r8340):  rafl | 2008-09-03 10:38:05 +0200
 Use Test::NoTabs instead of Test::Perl::Critic.
 r26507 at Command-Central (orig r8359):  rafl | 2008-09-05 17:50:16 +0200
 Make go('/chained/action') execute the full chain, not just the endpoint.
 r26508 at Command-Central (orig r8360):  rafl | 2008-09-05 20:55:52 +0200
 Fix ROADMAP url.



Property changes on: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates
___________________________________________________________________
Name: svk:merge
   - 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8295
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
   + 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8295
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:8360
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Changes
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Changes	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Changes	2008-09-07 13:04:19 UTC (rev 8362)
@@ -4,6 +4,7 @@
         - Port to Moose
         - Added test for action stringify
         - Added test for component instances getting $self->{value} from config.
+        - Chained doc improvements (rev 8326-8328)
 
 5.7XXXXXX XXXX
         - Fix some Win32 test failures

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Makefile.PL	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/Makefile.PL	2008-09-07 13:04:19 UTC (rev 8362)
@@ -34,7 +34,7 @@
 requires 'MRO::Compat';
 
 if (-e 'inc/.author') {
-  build_requires 'Test::Perl::Critic';
+  build_requires 'Test::NoTabs';
   build_requires 'Test::Pod' => 1.14;
   build_requires 'Test::Pod::Coverage' => 1.04;
 

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType/Chained.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType/Chained.pm	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType/Chained.pm	2008-09-07 13:04:19 UTC (rev 8362)
@@ -319,6 +319,23 @@
    
 }
 
+sub expand_action {
+    my ($self, $action) = @_;
+
+    return unless $action->attributes && $action->attributes->{Chained};
+
+    my @chain;
+    my $curr = $action;
+
+    while ($curr) {
+        push @chain, $curr;
+        my $parent = $curr->attributes->{Chained}->[0];
+        $curr = $self->_actions->{$parent};
+    }
+
+    return Catalyst::ActionChain->from_chain([reverse @chain]);
+}
+
 __PACKAGE__->meta->make_immutable;
 
 =head1 USAGE
@@ -496,13 +513,18 @@
 C</foo/bar/...>. If you don't specify C<:PathPart> it has the same
 effect as using C<:PathPart>, it would default to the action name.
 
+=item PathPrefix
+
+Sets PathPart to the path_prefix of the current controller.
+
 =item Chained
 
 Has to be specified for every child in the chain. Possible values are
-absolute and relative private action paths, with the relatives pointing
-to the current controller, or a single slash C</> to tell Catalyst that
-this is the root of a chain. The attribute C<:Chained> without arguments
-also defaults to the C</> behavior.
+absolute and relative private action paths or a single slash C</> to
+tell Catalyst that this is the root of a chain. The attribute
+C<:Chained> without arguments also defaults to the C</> behavior.
+Relative action paths may use C<../> to refer to actions in parent
+controllers.
 
 Because you can specify an absolute path to the parent action, it
 doesn't matter to Catalyst where that parent is located. So, if your
@@ -525,6 +547,19 @@
 C</foo/bar>. That action chains directly to C</>, so the C</bar/*/baz/*>
 chain comes out as the end product.
 
+=item ChainedParent
+
+Chains an action to another action with the same name in the parent
+controller. For Example:
+
+  # in MyApp::Controller::Foo
+  sub bar : Chained CaptureArgs(1) { ... }
+
+  # in MyApp::Controller::Foo::Moo
+  sub bar : ChainedParent Args(1) { ... }
+
+This builds a chain like C</bar/*/bar/*>.
+
 =item CaptureArgs
 
 Must be specified for every part of the chain that is not an

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType.pm	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/DispatchType.pm	2008-09-07 13:04:19 UTC (rev 8362)
@@ -58,6 +58,8 @@
 
 sub uri_for_action { }
 
+sub expand_action { }
+
 =head1 AUTHORS
 
 Catalyst Contributors, see Catalyst.pm

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/Dispatcher.pm	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/Dispatcher.pm	2008-09-07 13:04:19 UTC (rev 8362)
@@ -178,6 +178,8 @@
         return 0;
     }
 
+    $action = $self->expand_action($action);
+
     local $c->request->{arguments} = $args;
     $c->namespace($action->namespace);
     $c->action($action);
@@ -421,6 +423,17 @@
     return undef;
 }
 
+sub expand_action {
+    my ($self, $action) = @_;
+
+    foreach my $dispatch_type (@{ $self->_dispatch_types }) {
+        my $expanded = $dispatch_type->expand_action($action);
+        return $expanded if $expanded;
+    }
+
+    return $action;
+}
+
 =head2 $self->register( $c, $action )
 
 Make sure all required dispatch types for this action are loaded, then

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/ROADMAP.pod
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/ROADMAP.pod	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst/ROADMAP.pod	2008-09-07 13:04:19 UTC (rev 8362)
@@ -4,7 +4,7 @@
 for the Catalyst framework. It's liable to change at any time. This document
 lives in the the catalyst trunk, currently at 
 
-  http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst/lib/Catalyst/ROADMAP.pod
+  http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Runtime/5.80/trunk/lib/Catalyst/ROADMAP.pod
 
 Make sure you get it from there to ensure you have the latest version.
 

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst.pm	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/lib/Catalyst.pm	2008-09-07 13:04:19 UTC (rev 8362)
@@ -506,7 +506,7 @@
 sub _filter_component {
     my ( $c, $comp, @args ) = @_;
 
-    if ( eval { $comp->can('ACCEPT_CONTEXT'); } ) {
+    if ( Scalar::Util::blessed($c) && eval { $comp->can('ACCEPT_CONTEXT'); } ) {
         return $comp->ACCEPT_CONTEXT( $c, @args );
     }
     

Deleted: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.rc
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.rc	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.rc	2008-09-07 13:04:19 UTC (rev 8362)
@@ -1,5 +0,0 @@
-include  = CodeLayout::ProhibitHardTabs
-only     = 1
-
-[CodeLayout::ProhibitHardTabs]
-allow_leading_tabs = 0
\ No newline at end of file

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.t
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.t	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/04critic.t	2008-09-07 13:04:19 UTC (rev 8362)
@@ -9,14 +9,13 @@
     plan skip_all => 'Critic test only for developers.';
 }
 else {
-    eval { require Test::Perl::Critic };
+    eval { require Test::NoTabs };
     if ( $@ ) {
         plan tests => 1;
-        fail( 'You must install Test::Perl::Critic to run 04critic.t' );
+        fail( 'You must install Test::NoTabs to run 04critic.t' );
         exit;
     }
 }
 
-my $rcfile = File::Spec->catfile( 't', '04critic.rc' );
-Test::Perl::Critic->import( -profile => $rcfile );
-all_critic_ok();
\ No newline at end of file
+Test::NoTabs->import;
+all_perl_files_ok(qw/lib/);

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_component.t
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_component.t	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_component.t	2008-09-07 13:04:19 UTC (rev 8362)
@@ -73,16 +73,20 @@
 {
     my $args;
 
-    no warnings; 
-    *MyApp::M::Model::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+    {
+        no warnings 'once';
+        *MyApp::M::Model::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+    }
 
-    MyApp->component('MyApp::M::Model', qw/foo bar/);
+    my $c = bless {}, 'MyApp';
+
+    $c->component('MyApp::M::Model', qw/foo bar/);
     is_deeply($args, [qw/foo bar/], 'args passed to ACCEPT_CONTEXT ok');
 
-    MyApp->component('M::Model', qw/foo2 bar2/);
+    $c->component('M::Model', qw/foo2 bar2/);
     is_deeply($args, [qw/foo2 bar2/], 'args passed to ACCEPT_CONTEXT ok');
 
-    MyApp->component('Mode', qw/foo3 bar3/);
+    $c->component('Mode', qw/foo3 bar3/);
     is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok');
 } 
 

Modified: Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_mvc.t
===================================================================
--- Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_mvc.t	2008-09-05 21:33:25 UTC (rev 8361)
+++ Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates/t/unit_core_mvc.t	2008-09-07 13:04:19 UTC (rev 8362)
@@ -1,4 +1,4 @@
-use Test::More tests => 44;
+use Test::More tests => 45;
 use strict;
 use warnings;
 
@@ -150,17 +150,25 @@
 {
     my $args;
 
-    no warnings; 
-    *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
-    *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+    {
+        no warnings 'once';
+        *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+        *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+    }
 
-    MyApp->model('M', qw/foo bar/);
+    my $c = bless {}, 'MyApp';
+
+    $c->model('M', qw/foo bar/);
     is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok');
 
-    my $x = MyApp->view('V', qw/foo2 bar2/);
+    my $x = $c->view('V', qw/foo2 bar2/);
     is_deeply($args, [qw/foo2 bar2/], '$c->view args passed to ACCEPT_CONTEXT ok');
 
     # regexp fallback
-    MyApp->view('::View::V', qw/foo3 bar3/);
+    $c->view('::View::V', qw/foo3 bar3/);
     is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok');
+
+    undef $args;
+    MyApp->model('M', qw/foo bar/);
+    is($args, undef, 'MyApp->model does not invoke ACCEPT_CONTEXT');
 }




More information about the Catalyst-commits mailing list