Skip Menu |

This queue is for tickets about the Catalyst-Action-REST CPAN distribution.

Report information
The Basics
Id: 32042
Status: resolved
Priority: 0/
Queue: Catalyst-Action-REST

People
Owner: claco [...] cpan.org
Requestors: claco [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Param::Validate import is subclass unfriendly
When subclassing Controller::REST with code that provides its own validate() method doesn't play well with the validate() function that is imported by Param::Validate Attached is a patch that removes the import, and calls Params::Validate::validate directly.
Subject: REST-1116.patch
=== lib/Catalyst/Controller/REST.pm ================================================================== --- lib/Catalyst/Controller/REST.pm (revision 1116) +++ lib/Catalyst/Controller/REST.pm (local) @@ -208,7 +208,7 @@ use strict; use warnings; use base 'Catalyst::Controller'; -use Params::Validate qw(:all); +use Params::Validate (); __PACKAGE__->mk_accessors(qw(serialize)); @@ -255,7 +255,7 @@ 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'} ); @@ -285,7 +285,7 @@ sub status_created { my $self = shift; my $c = shift; - my %p = validate( + my %p = Params::Validate::validate( @_, { location => { type => SCALAR | OBJECT }, @@ -323,7 +323,7 @@ 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'} ); @@ -348,7 +348,7 @@ 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'} ); @@ -374,7 +374,7 @@ 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'} );
On Wed Jan 02 00:00:25 2008, CLACO wrote: Show quoted text
> When subclassing Controller::REST with code that provides its own > validate() method doesn't play well with the validate() function that is > imported by Param::Validate > > Attached is a patch that removes the import, and calls > Params::Validate::validate directly. >
Bah. First patch sucks. Needs to import SCALAR/OBJECT. Here's an updated one.
--- REST.pm.orig 2008-01-02 00:12:43.000000000 -0500 +++ REST.pm 2008-01-02 00:34:36.000000000 -0500 @@ -208,7 +208,7 @@ use strict; use warnings; use base 'Catalyst::Controller'; -use Params::Validate qw(:all); +use Params::Validate qw/SCALAR OBJECT/; __PACKAGE__->mk_accessors(qw(serialize)); @@ -255,7 +255,7 @@ 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'} ); @@ -285,7 +285,7 @@ sub status_created { my $self = shift; my $c = shift; - my %p = validate( + my %p = Params::Validate::validate( @_, { location => { type => SCALAR | OBJECT }, @@ -323,7 +323,7 @@ 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'} ); @@ -348,7 +348,7 @@ 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; @@ -374,7 +374,7 @@ 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;
Fixed in 0.60