[Catalyst-commits] r13558 - in Catalyst-Runtime/5.80/branches/forward-comp-obj: lib/Catalyst t/aggregate t/lib

edenc at dev.catalyst.perl.org edenc at dev.catalyst.perl.org
Mon Aug 30 00:05:19 GMT 2010


Author: edenc
Date: 2010-08-30 01:05:19 +0100 (Mon, 30 Aug 2010)
New Revision: 13558

Modified:
   Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Action.pm
   Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Controller.pm
   Catalyst-Runtime/5.80/branches/forward-comp-obj/t/aggregate/unit_core_action.t
   Catalyst-Runtime/5.80/branches/forward-comp-obj/t/lib/TestAppDoubleAutoBug.pm
Log:
adding a component object for every action

Modified: Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Action.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Action.pm	2010-08-29 13:58:01 UTC (rev 13557)
+++ Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Action.pm	2010-08-30 00:05:19 UTC (rev 13558)
@@ -25,7 +25,32 @@
 use namespace::clean -except => 'meta';
 
 has class => (is => 'rw');
-has component => (is => 'rw');
+has component => (is => 'ro'); #, required => 1);
+
+# 18:08 @t0m:» edenc: Why not change action construction in other places also
+#              so that the controller instance is always passed in
+# 18:09 @t0m:» And you can make the new attribute ro, right?
+# 18:13 @t0m:» edenc: yy, the 'forward to component' case, where an action is
+#              pulled out of the dispatcher's ass, on request.. Sets the
+#              component instance
+# 18:14 @t0m:» But 'normal' actions, constructed in a controller, don't.
+# 18:14 @edenc:» oh, right
+# 18:15 @edenc:» yeah well, I wanted to stick to minimal disruption of the
+#                current code
+# 18:17 @t0m:» I get you, but I'm thinking we should try to keep actions
+#              having the same state in all cases.. The fall back to the
+#              component name you added entirely needs to stay for compat, but
+#              I think it'd be nice if all 'normal' cases have the same state.
+#              The (small) extra disruption is worth the simplification in
+#              terms of the attribute always being filled .
+# 18:17 @t0m:» Does that make sense?
+# 18:17 @edenc:» yes
+# 18:18 @t0m:» cool. I'd like to say 'make it required', but that'll entirely
+#              break someone, somewhere :)
+# 18:20 @t0m:» right, lets assume we would if we could, and make the tests
+#              pass with it required, but not actually turn required on?
+# 18:22 @edenc:» t0m++
+
 has namespace => (is => 'rw');
 has 'reverse' => (is => 'rw');
 has attributes => (is => 'rw');

Modified: Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Controller.pm	2010-08-29 13:58:01 UTC (rev 13557)
+++ Catalyst-Runtime/5.80/branches/forward-comp-obj/lib/Catalyst/Controller.pm	2010-08-30 00:05:19 UTC (rev 13558)
@@ -274,7 +274,7 @@
         %{ $action_args->{ $args{name} } || {} },
     );
 
-    return $class->new({ %extra_args, %args });
+    return $class->new({ %extra_args, %args, component => $self });
 }
 
 sub _parse_attrs {

Modified: Catalyst-Runtime/5.80/branches/forward-comp-obj/t/aggregate/unit_core_action.t
===================================================================
--- Catalyst-Runtime/5.80/branches/forward-comp-obj/t/aggregate/unit_core_action.t	2010-08-29 13:58:01 UTC (rev 13557)
+++ Catalyst-Runtime/5.80/branches/forward-comp-obj/t/aggregate/unit_core_action.t	2010-08-30 00:05:19 UTC (rev 13558)
@@ -12,6 +12,7 @@
   code => sub { "DUMMY" },
   reverse => 'bar/foo',
   namespace => 'bar',
+  component => bless({}, 'DUMMY'),
   attributes => {
     Args => [ 1 ],
     attr2 => [ 2 ],
@@ -23,6 +24,7 @@
   code => sub { "DUMMY" },
   reverse => 'bar/foo',
   namespace => 'bar',
+  component => bless({}, 'DUMMY'),
   attributes => {
     Args => [ 2 ],
     attr2 => [ 2 ],

Modified: Catalyst-Runtime/5.80/branches/forward-comp-obj/t/lib/TestAppDoubleAutoBug.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/forward-comp-obj/t/lib/TestAppDoubleAutoBug.pm	2010-08-29 13:58:01 UTC (rev 13557)
+++ Catalyst-Runtime/5.80/branches/forward-comp-obj/t/lib/TestAppDoubleAutoBug.pm	2010-08-30 00:05:19 UTC (rev 13558)
@@ -17,7 +17,7 @@
 
 sub execute {
     my $c      = shift;
-    my $class  = ref( $c->component( $_[0] ) ) || $_[0];
+    my $class  = ref( $c->component( $_[0] ) ) || ref( $_[0] ) || $_[0];
     my $action = $_[1]->reverse();
 
     my $method;




More information about the Catalyst-commits mailing list