[Catalyst] A point of confusion/frustration on chained actions

Ido Perlmuter ido at ido50.net
Wed May 19 22:32:07 GMT 2010


As far as I understand from your message, the solution is quite easy. You're
problem is due to the fact that Catalyst forces you to define end-points and
mid-points for your chain. Sometimes you need to have an action which can
double both as a mid-point and as an end-point, as with your
/tutorial/*/comment/* and /tutorial/*/comment/*/replies example. In this
case all you have to do is create the comment action as a mid point, and
then create another action with a different name, but the same PathPart
(e.g. comment) only this time as an end-point, and all this action needs to
do is forward or detach to the original action (also passing any parameters
it needs).


Sent from my iPhone, so expect a lot of spelling errors and stuff.

On 20/05/2010, at 01:16, Stephen Howard <stephen at enterity.com> wrote:

I am trying to sort out some interdependent chains and I'm having trouble
figuring out why the urls I'm trying to build aren't working out.

I have a site where the primary objects of interest are flash-based
tutorials.  Each tutorial can have comments, and each comment can have
replies.  I'm using jQuery to manipulate comments in a REST fashion, and I'm
aiming for a url map like this:

/tutorials                         # GET a list of tutorials, or POST a new
tutorial
/tutorials/*                       # GET/POST/DELETE a specific tutorial
/tutorials/*/comments              # GET the comments for a tutorial, or
POST a new comment
/tutorials/*/comments/*            # GET/POST/DELETE a specific comment
/tutorials/*/comments/*/replies    # GET the replies for a comment, or POST
a new reply
/tutorials/*/comments/*/replies/*  # GET/POST/DELETE a specific reply

But the best I've been able to come up with is this:

 /tutorials
^tutorials/(\d+)$
/tutorial/*/comments
/tutorial/*/comment/*/replies
/tutorial/*/comment/*/reply/*

missing: /tutorial/*/comment (what would I call it? /tutorial/*/cmt ?)

Essentially I'm hitting an issue with is due to the (seeming?) impossibility
of matching a chained set of actions at multiple url depths. Is it possible
to build the url structure I'm looking for above using chained actions?

thanks,
Stephen

_______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100520/635c1=
b42/attachment.htm


More information about the Catalyst mailing list