[Catalyst] Quesion about Chaining usage

Lee Standen nom at standen.id.au
Tue Sep 5 06:54:09 CEST 2006


I've been out of Cat development for a while, so take this with a grain 
of salt.

I always found you could do that by doing something like:

myapp/C/Feedrolls.pm:

sub default : Private {
    my ($self,$c) = @_;
   
    my($feedroll_id,$feed_id, at others) = @{$c->req->args};
}

Then you can do whatever you need to do with them.
Someone want to correct me? :)



John Napiorkowski wrote:
> Just as an update, I am guessing it's something do to
> with the PathPart usage in my example.  I'm setting
> most of them blank, since I'm looking for simple
> chains of ids in my url like so:
>
> /feedrolls/[feedroll_id]/[feed_id]
>
> Now if I set all the PathParts to their defaults I get
> urls like:
>
> /feedrolls/feedroll/1/feedroll_list
>
> And it works in the manner I want without error, just
> that I want cleaner looking URLS.  Suggestions
> appreciated!
>
> --john
>
> --- John Napiorkowski <jjn1056 at yahoo.com> 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?
>>
>> --john
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam
>> protection around 
>> http://mail.yahoo.com 
>>
>> _______________________________________________
>> List: Catalyst at lists.rawmode.org
>> Listinfo:
>> http://lists.rawmode.org/mailman/listinfo/catalyst
>> Searchable archive:
>>
>>     
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
>   
>> Dev site: http://dev.catalyst.perl.org/
>>
>>     
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
>   




More information about the Catalyst mailing list