[Catalyst] Quesion about Chaining usage
Matt S Trout
dbix-class at trout.me.uk
Tue Sep 5 12:14:04 CEST 2006
John Napiorkowski wrote:
> 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?
Not without the startup debug output for your app showing the path part
dispatch table ...
MORE INFORMATION! MORE INFORMATION! MORE INFORMATION!
(MORE CAFFEINE! :)
--
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/ +
More information about the Catalyst
mailing list