[Catalyst-commits] r14145 - in Catalyst-Plugin-Params-Nested/trunk: . lib/Catalyst/Plugin/Params t

dpetrov at dev.catalyst.perl.org dpetrov at dev.catalyst.perl.org
Tue Nov 8 11:30:16 GMT 2011


Author: dpetrov
Date: 2011-11-08 11:30:16 +0000 (Tue, 08 Nov 2011)
New Revision: 14145

Modified:
   Catalyst-Plugin-Params-Nested/trunk/Changes
   Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm
   Catalyst-Plugin-Params-Nested/trunk/t/basic.t
Log:
Hook into prepare_uploads instead of prepare_parameters

Modified: Catalyst-Plugin-Params-Nested/trunk/Changes
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/Changes	2011-11-08 11:29:32 UTC (rev 14144)
+++ Catalyst-Plugin-Params-Nested/trunk/Changes	2011-11-08 11:30:16 UTC (rev 14145)
@@ -1,3 +1,7 @@
+        - Hook into prepare_uploads instead of prepare_parameters
+          (since uploads are also added to the request parameters,
+           we need to hook here to expand uploads parameters)
+
 - 0.04 2010-07-28 22:31:44
         - Fixed RT:59604 `param[]` causing copy to `param` (ECARROLL)
 

Modified: Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm	2011-11-08 11:29:32 UTC (rev 14144)
+++ Catalyst-Plugin-Params-Nested/trunk/lib/Catalyst/Plugin/Params/Nested.pm	2011-11-08 11:30:16 UTC (rev 14145)
@@ -10,7 +10,7 @@
 
 our $VERSION = "0.04";
 
-sub prepare_parameters {
+sub prepare_uploads {
     my $c = shift;
     my $ret = $c->maybe::next::method( @_ );
 
@@ -93,9 +93,9 @@
 
 =over 4
 
-=item prepare_parameters
+=item prepare_uploads
 
-Overrides L<Catalyst/prepare_parameters> to expand the parameter data structure
+Overrides L<Catalyst/prepare_uploads> to expand the parameter data structure
 post factum.
 
 =back

Modified: Catalyst-Plugin-Params-Nested/trunk/t/basic.t
===================================================================
--- Catalyst-Plugin-Params-Nested/trunk/t/basic.t	2011-11-08 11:29:32 UTC (rev 14144)
+++ Catalyst-Plugin-Params-Nested/trunk/t/basic.t	2011-11-08 11:30:16 UTC (rev 14145)
@@ -23,36 +23,36 @@
   }
 );
 
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, {}, "no params");
 
 %$params = ( foo => 1 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { foo => 1 }, "params not touched");
 
 %$params = ( 'foo[bar]' => 1 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { 'foo[bar]' => 1, 'foo' => { bar => 1 } }, "params expanded 1 level deep");
 
 %$params = ( 'foo[]' => 1 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { 'foo[]' => 1 }, "Empty first-level param not touched");
 
 %$params = ( 'foo[bar][gorch]' => 1 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { 'foo[bar][gorch]' => 1, 'foo' => { bar => { gorch => 1 } } }, "params expanded 2 levels deep");
 
 
 
 %$params = ( 'foo[bar][gorch]' => 1, 'foo[bar][baz]' => 2 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { 'foo[bar][baz]' => 2, 'foo[bar][gorch]' => 1, 'foo' => { bar => { gorch => 1, baz => 2 } } }, "params expanded 2 levels deep, multiple subkeys");
 
 %$params = ( 'foo.bar.gorch' => 1, 'foo.bar.baz' => 2 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { 'foo.bar.baz' => 2, 'foo.bar.gorch' => 1, 'foo' => { bar => { gorch => 1, baz => 2 } } }, "params expanded 2 levels deep, multiple subkeys, dot notation");
 
 %$params = ( 'submit' => 1, 'submit.x' => 2, 'submit.y' => 3 );
-$c->prepare_parameters;
+$c->prepare_uploads;
 is_deeply( $params, { submit => 1, 'submit.x' => 2, 'submit.y' => 3 },
            "params did not expand /\.[xy]$/" );




More information about the Catalyst-commits mailing list