From: claco Date: Fri, 4 Jan 2008 00:47:29 +0000 (+0000) Subject: r1144@mbp: claco | 2008-01-03 19:43:42 -0500 X-Git-Tag: 1.08~262 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4611771994693e9145e19c00c4b2d5bc7b485eb;p=catagits%2FCatalyst-Action-Serialize-Data-Serializer.git r1144@mbp: claco | 2008-01-03 19:43:42 -0500 Fixed RT#30498 - REST controller references Catalyst without loading it first. Fixed RT#32042 - Import of Params::Validate :all plays badly with subclasses that have their own validate() Fixed RT#30456 - Debug messages print even with debugging disabled --- diff --git a/Changelog b/Changelog index e9c1f42..ad68a4f 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,13 @@ +Thu Jan 3 19:42:16 EST 2008 + Fixed RT#30498 - REST controller references Catalyst without + loading it first. + Fixed RT#32042 - Import of Params::Validate :all plays badly + with subclasses that have their own validate() + Fixed RT#30456 - Debug messages print even with debugging disabled + Thu Jan 3 08:54:09 PST 2008 Fixed an issue where YAML::Syck versions 0.92 require $c->request->body to - be stringified + be stringified Fri Dec 21 15:23:46 EDT 2007 Updated the configuration specifiers to operate more in line with the way diff --git a/lib/Catalyst/Action/Deserialize/Data/Serializer.pm b/lib/Catalyst/Action/Deserialize/Data/Serializer.pm index 7044655..ab2aafe 100644 --- a/lib/Catalyst/Action/Deserialize/Data/Serializer.pm +++ b/lib/Catalyst/Action/Deserialize/Data/Serializer.pm @@ -24,7 +24,8 @@ sub execute { require $sp }; if ($@) { - $c->log->debug("Could not load $serializer, refusing to serialize: $@"); + $c->log->debug("Could not load $serializer, refusing to serialize: $@") + if $c->debug; return 0; } my $body = $c->request->body; @@ -48,7 +49,8 @@ sub execute { $c->request->data($rdata); } else { $c->log->debug( - 'I would have deserialized, but there was nothing in the body!'); + 'I would have deserialized, but there was nothing in the body!') + if $c->debug; } return 1; } diff --git a/lib/Catalyst/Action/Deserialize/XML/Simple.pm b/lib/Catalyst/Action/Deserialize/XML/Simple.pm index 6e97d72..8d96425 100644 --- a/lib/Catalyst/Action/Deserialize/XML/Simple.pm +++ b/lib/Catalyst/Action/Deserialize/XML/Simple.pm @@ -20,7 +20,8 @@ sub execute { require XML::Simple; }; if ($@) { - $c->log->debug("Could not load XML::Simple, refusing to deserialize: $@"); + $c->log->debug("Could not load XML::Simple, refusing to deserialize: $@") + if $c->debug; return 0; } @@ -41,7 +42,8 @@ sub execute { } } else { $c->log->debug( - 'I would have deserialized, but there was nothing in the body!'); + 'I would have deserialized, but there was nothing in the body!') + if $c->debug; } return 1; } diff --git a/lib/Catalyst/Action/REST.pm b/lib/Catalyst/Action/REST.pm index 94d6e70..9cb5a78 100644 --- a/lib/Catalyst/Action/REST.pm +++ b/lib/Catalyst/Action/REST.pm @@ -12,6 +12,7 @@ use warnings; use base 'Catalyst::Action'; use Class::Inspector; +use Catalyst; use Catalyst::Request::REST; use 5.8.1; diff --git a/lib/Catalyst/Action/Serialize/XML/Simple.pm b/lib/Catalyst/Action/Serialize/XML/Simple.pm index 668e3f5..aed9561 100644 --- a/lib/Catalyst/Action/Serialize/XML/Simple.pm +++ b/lib/Catalyst/Action/Serialize/XML/Simple.pm @@ -20,7 +20,8 @@ sub execute { require XML::Simple }; if ($@) { - $c->log->debug("Could not load XML::Serializer, refusing to serialize: $@"); + $c->log->debug("Could not load XML::Serializer, refusing to serialize: $@") + if $c->debug; return 0; } my $xs = XML::Simple->new(ForceArray => 0,); diff --git a/lib/Catalyst/Action/SerializeBase.pm b/lib/Catalyst/Action/SerializeBase.pm index db5d42e..7dfe1e8 100644 --- a/lib/Catalyst/Action/SerializeBase.pm +++ b/lib/Catalyst/Action/SerializeBase.pm @@ -36,7 +36,7 @@ sub _load_content_plugins { $self->_serialize_plugins( \@plugins ); } - my $content_type = $c->request->preferred_content_type; + my $content_type = $c->request->preferred_content_type || ''; # Finally, we load the class. If you have a default serializer, # and we still don't have a content-type that exists in the map, @@ -94,8 +94,7 @@ sub _load_content_plugins { eval { require $load_class; }; if ($@) { $c->log->error( - "Error loading $sclass for " . $content_type . ": $!" ) - if $c->log->is_debug; + "Error loading $sclass for " . $content_type . ": $!" ); return $self->_unsupported_media_type($c, $content_type); } else { $self->_loaded_plugins->{$sclass} = 1; diff --git a/lib/Catalyst/Controller/REST.pm b/lib/Catalyst/Controller/REST.pm index 6123010..5d267b3 100644 --- a/lib/Catalyst/Controller/REST.pm +++ b/lib/Catalyst/Controller/REST.pm @@ -208,7 +208,7 @@ such require you pass the current context ($c) as the first argument. use strict; use warnings; use base 'Catalyst::Controller'; -use Params::Validate qw(:all); +use Params::Validate qw(SCALAR OBJECT); __PACKAGE__->mk_accessors(qw(serialize)); @@ -253,7 +253,7 @@ Example: sub status_ok { my $self = shift; my $c = shift; - my %p = validate( @_, { entity => 1, }, ); + my %p = Params::Validate::validate( @_, { entity => 1, }, ); $c->response->status(200); $self->_set_entity( $c, $p{'entity'} ); @@ -283,7 +283,7 @@ This is probably what you want for most PUT requests. sub status_created { my $self = shift; my $c = shift; - my %p = validate( + my %p = Params::Validate::validate( @_, { location => { type => SCALAR | OBJECT }, @@ -321,7 +321,7 @@ Example: sub status_accepted { my $self = shift; my $c = shift; - my %p = validate( @_, { entity => 1, }, ); + my %p = Params::Validate::validate( @_, { entity => 1, }, ); $c->response->status(202); $self->_set_entity( $c, $p{'entity'} ); @@ -346,7 +346,7 @@ Example: sub status_bad_request { my $self = shift; my $c = shift; - my %p = validate( @_, { message => { type => SCALAR }, }, ); + my %p = Params::Validate::validate( @_, { message => { type => SCALAR }, }, ); $c->response->status(400); $c->log->debug( "Status Bad Request: " . $p{'message'} ) if $c->debug; @@ -372,7 +372,7 @@ Example: sub status_not_found { my $self = shift; my $c = shift; - my %p = validate( @_, { message => { type => SCALAR }, }, ); + my %p = Params::Validate::validate( @_, { message => { type => SCALAR }, }, ); $c->response->status(404); $c->log->debug( "Status Not Found: " . $p{'message'} ) if $c->debug;