[Catalyst] Re: Validating single arg id
Aristotle Pagaltzis
pagaltzis at gmx.de
Wed Oct 21 13:52:27 GMT 2009
* Zbigniew Lukasiak <zzbbyy at gmail.com> [2009-10-21 14:15]:
> What is the advantage of this over:
>
> sub view : Local {
> my ( $self, $c, $id ) = @_;
> $self->start( $c, $id );
> # do something with $c->stash->{obj}
> return 1;
> }
Consider `/forum/7/topic/13/post/4/editform`. The end point in
that chain would be
sub editform : Chained('post') {
my ( $self, $c ) = @_;
# ...
}
The equivalent URI with Local would be `/editpost/7/13/4` and the
action would look like this:
sub editform : Local {
my ( $self, $c, $forum, $topic, $post ) = @_;
$self->load_post( $forum, $topic, $post );
# ...
}
(And then of course `load_post` would have to look something like
the following.)
sub load_post {
my ( $self, $forum, $topic, $post ) = @_;
$self->load_topic( $forum, $topic );
# ...
}
Notice what’s going on with the argument lists between the two
examples.
Which code structure looks more DRY and which URI structure more
consistent to you?
--
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Catalyst
mailing list