From: Tomas Doran Date: Sat, 27 Dec 2008 22:40:10 +0000 (+0000) Subject: Replace {_body} instance access with calls to _body accessors.. X-Git-Tag: 5.8000_05~65 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=0f56bbcf00b69a018aa6be442200b917b3e9f9a2 Replace {_body} instance access with calls to _body accessors.. --- diff --git a/TODO b/TODO index 694dc0e..8aef224 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,8 @@ Pending patches: - Re-opening packages with MX::Emulate::CAF (for Catalyst::Plugin::HashedCookies) + + - Double-applying mk_accessors breaks, t/double_apply.t for MX::Emulate::CAF Back-compat investigation / known issues: @@ -68,8 +70,6 @@ Cleanups: - After that set up attr handlers that will output helpful error messages when you do it as well as how to fix it. (done already?) - - Comments marked /Moose TODO/i in Catalyst::Request re {_body} (t0m) - - Eliminate all instances of $instance->{$key}, I think the only thing left is lib/Catalyst/Engine/HTTP.pm: $self->{inputbuf}, which I haven't touched as it is used as an lvalue in a lot of places (t0m) diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index a1fc1fb..d387099 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1747,9 +1747,7 @@ Prepares message body. sub prepare_body { my $c = shift; - #Moose TODO: what is _body ?? - # Do we run for the first time? - return if defined $c->request->{_body}; + return if $c->request->_has_body; # Initialize on-demand data $c->engine->prepare_body( $c, @_ ); diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index b751ba3..b0b5243 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -129,7 +129,7 @@ sub finalize_error { $c->res->_clear_context; # Don't show body parser in the dump - delete $c->req->{_body}; + $c->req->_clear_body; my @infos; my $i = 0; @@ -313,10 +313,10 @@ sub prepare_body { if ( my $length = $self->read_length ) { my $request = $c->request; - unless ( $request->{_body} ) { + unless ( $request->_body ) { my $type = $request->header('Content-Type'); - $request->{_body} = HTTP::Body->new( $type, $length ); - $request->{_body}->tmpdir( $c->config->{uploadtmp} ) + $request->_body(HTTP::Body->new( $type, $length )); + $request->_body->tmpdir( $c->config->{uploadtmp} ) if exists $c->config->{uploadtmp}; } @@ -334,7 +334,7 @@ sub prepare_body { } else { # Defined but will cause all body code to be skipped - $c->request->{_body} = 0; + $c->request->_body(0); } } @@ -347,7 +347,7 @@ Add a chunk to the request body. sub prepare_body_chunk { my ( $self, $c, $chunk ) = @_; - $c->request->{_body}->add($chunk); + $c->request->_body->add($chunk); } =head2 $self->prepare_body_parameters($c) @@ -359,9 +359,9 @@ Sets up parameters from body. sub prepare_body_parameters { my ( $self, $c ) = @_; - return unless $c->request->{_body}; + return unless $c->request->_body; - $c->request->body_parameters( $c->request->{_body}->param ); + $c->request->body_parameters( $c->request->_body->param ); } =head2 $self->prepare_connection($c) @@ -511,9 +511,9 @@ sub prepare_uploads { my ( $self, $c ) = @_; my $request = $c->request; - return unless $request->{_body}; + return unless $request->_body; - my $uploads = $request->{_body}->upload; + my $uploads = $request->_body->upload; my $parameters = $request->parameters; foreach my $name (keys %$uploads) { my $files = $uploads->{$name}; diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index f228099..da5d3e4 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -97,7 +97,7 @@ has base => ( ); has _body => ( - is => 'rw', + is => 'rw', clearer => '_clear_body', predicate => '_has_body', ); # Eugh, ugly. Should just be able to rename accessor methods to 'body' # and provide a custom reader..