From: Tomas Doran Date: Fri, 15 May 2009 09:41:11 +0000 (+0000) Subject: Fix on demand parsing of ->req->parameters X-Git-Tag: 5.80004~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=341620d5b5a0e4f2d77fbe614c810dca47d2006f Fix on demand parsing of ->req->parameters --- diff --git a/Changes b/Changes index a48da4b..6c64991 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,8 @@ to report 'Unknown Error' (t0m) - Support adding Moose::Roles to the plugin list. These are applied to MyApp after plugins have been pushed onto @ISA (t0m) + - Fix calling $c->req->parameters as the first thing you do when + parse_on_demand is on (t0m) 5.80003 2009-04-29 16:23:53 - Various POD tweaks. (hdp, dandv) diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index 81bda0f..a488acd 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -36,14 +36,6 @@ has headers => ( lazy => 1, ); -# Moose TODO: -# - Can we lose the before modifiers which just call prepare_body ? -# they are wasteful, slow us down and feel cluttery. -# Can we call prepare_body at BUILD time? -# Can we make _body an attribute, have the rest of -# these lazy build from there and kill all the direct hash access -# in Catalyst.pm and Engine.pm? - has _context => ( is => 'rw', weak_ref => 1, @@ -58,11 +50,6 @@ has body_parameters => ( default => sub { {} }, ); -before body_parameters => sub { - my ($self) = @_; - $self->_context->prepare_body(); -}; - has uploads => ( is => 'rw', required => 1, @@ -76,6 +63,20 @@ has parameters => ( default => sub { {} }, ); +# TODO: +# - Can we lose the before modifiers which just call prepare_body ? +# they are wasteful, slow us down and feel cluttery. + +# Can we make _body an attribute, have the rest of +# these lazy build from there and kill all the direct hash access +# in Catalyst.pm and Engine.pm? + +before $_ => sub { + my ($self) = @_; + my $context = $self->_context || return; + $context->prepare_body; +} for qw/parameters body_parameters/; + around parameters => sub { my ($orig, $self, $params) = @_; if ($params) {