[Catalyst] Quesion about Chaining usage

John Napiorkowski jjn1056 at yahoo.com
Tue Sep 5 02:58:52 CEST 2006


I've notices what I think is somewhat strange behavior
in a chain I've created, although as usual it might
just be my ignorance.  Here's is a skeleton of the
chain I made:

package myapp::Controller::Feedrolls

sub feedrolls :Chained('/') CaptureArgs(0){}

sub feedrolls_all :Chained('feedrolls') PathPart('')
Args(0) {}

sub feedroll :Chained('feedrolls') PathPart('')
CaptureArgs(1) { my ($self, $c, $captured) = @_; }

sub feedroll_all :Chained('feedroll') PathPart('')
Args(0) {}

When I run catalyst I get a mapping like this:

(1) /feedrolls/*
(2) /feedrolls

(1) chains from feedrolls to feedroll to feedroll_all
and (2) chains from feedrolls to feedrolls_all.

Okay so far so good.  However when I try to call the
action through the browser at
"http://localhost/feedrolls" I get an error about the
$captured variable being undefined, which is strange
to me since I am thinking that to get to the
containing sub I need to use an action link
"/feedrolls/[feedroll_id]".  When I look at the debug
output to see what is getting called I can see that
indee that chain is going from feedrolls to feedroll
to feedroll_all instead of from feedrolls to feedrolls
all.

What is even stranger is that if I change the sub:

sub feedroll :Chained('feedrolls') PathPart('')
CaptureArgs(1) { my ($self, $c, $captured) = @_; }

to 

sub feedroll :Chained('feedrolls') PathPart('')
Args(1) { my ($self, $c, $captured) = @_; }

and handle all the processing there instead of the way
I outlined it above, everything works as expected.

So there seems to be something strange here, since
merely terminating the chain one sub earlier changes
the ways things get called quite a bit.

So... Can anyone spot if there is something wrong in
the way I am doing this?

--john



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Catalyst mailing list