[Catalyst-dev] [OT] suggestion to augment the default view
John Napiorkowski
jjn1056 at yahoo.com
Wed Sep 6 18:10:08 CEST 2006
Hi,
I'm trying to hack up this action class to match on
the request method but I have a question about using
NEXT in this context. I assume I need to use NEXT to
pass this on to the next match(er) for the action but
I am having trouble conceptualizing it. Should It
look like this do you think?
sub match
{
my $self = shift @_;
my ($c) = @_;
## Check for Methods attribute
return 1 unless exists $self->attributes->{Methods};
## Get the array of methods.
my @methods = @{$self->attributes->{Methods}};
while (my $method = @methods)
{
return if $method eq $c->request->method;
}
## No matching method..
return 0;
## Or should I use next to check the next match?
return $self->NEXT::match( @_ );
}
I am envisioning this would work like:
sub action ActionClass('Rest') Methods(qw/GET HEAD/)
{}
Or something to that effect.
One question for how people might prefer this to work.
I am also going to create a pre execute sub to parse
the submitted body for PUT and POST into a suitable
XML object, such as XML::Simple. Would you all prefer
I load this into the stash, under say:
$c->stash->{rest_body}->....
Or do you think this go into the
$c->response->body_parameters methods? I am concerned
to pollute the $c->[....] namespace with yet another
methods of my own choice.
Thoughts?
--John
--- Matt S Trout <dbix-class at trout.me.uk> wrote:
> John Napiorkowski wrote:
> > I was also thinking this could be a renderview
> class
> > to act as a post operation. This is starting to
> sound
> > like a better idea now that you tell me about the
> > changes for the next version.
> >
> > Maybe this is a silly question but can you have
> more
> > than one renderview class per method? Because I
> am
> > thinking of a couple of these I could use. I
> guess I
> > could write a class to contain several if not...
> >
> > Oh, and does anyone know of a way to use an
> > actionclass to force an action to fail to match?
> What
> > I am trying to do is create a neater way to handle
> my
> > REST based actions. Right now I do something
> like:
>
> Yes, override "sub match" in your actionclass. The
> current one is what handles
> :Args, see Catalyst::Action for more details
>
> --
> Matt S Trout Offering custom
> development, consultancy and support
> Technical Director contracts for Catalyst,
> DBIx::Class and BAST. Contact
> Shadowcat Systems Ltd. mst (at)
> shadowcatsystems.co.uk for more information
>
> + Help us build a better perl ORM:
> http://dbix-class.shadowcatsystems.co.uk/ +
>
> _______________________________________________
> Catalyst-dev mailing list
> Catalyst-dev at lists.rawmode.org
>
http://lists.rawmode.org/mailman/listinfo/catalyst-dev
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Catalyst-dev
mailing list