[Catalyst] Chained actions with can't terminate with :PathPart('') ?

Trevor Leffler tleffler at uw.edu
Fri May 7 18:23:33 GMT 2010


Oh, and to be clear about the example controllers, they'd be named:

::Root, ::Company, and ::Company::Lot.

--Trevor

Trevor Leffler wrote:
> Evan,
> 
> Here's an example of chaining that breaks out a lot of your path parts 
> into discreet methods.  Watch the server debug output while hitting 
> these in your browser to see how each piece is executed.
> 
> Notice how "middle man" methods use :CaptureArgs while endpoints use 
> :Args.  Also, each piece of the chain uses :PathPart, rather than :Path, 
> and it cannot be omitted.
> 
> Your application may not need or want all the controllers, methods, and 
> endpoints I set up here, so play around with it.  Read also about how 
> auto() and begin() might play a role in your controller hierarchy.
> 
> [root controller]
> sub auth : Chained('/') : PathPart('auth') : CaptureArgs(0) { }
> 
> [company controller]
> sub base : Chained('/auth') : PathPart('company') : CaptureArgs(0) { }
> sub list : Chained('base') : PathPart('') : Args(0) { }
> sub base_view : Chained('base') : PathPart('') : CaptureArgs(1) { }
> sub view : Chained('base_view') : PathPart('') : Args(0) { }
> 
> [lot controller]
> sub base : Chained('/company/base_view') : PathPart('lot') : 
> CaptureArgs(0) { }
> sub list : Chained('base') : PathPart('') : Args(0) { }
> sub view : Chained('base') : PathPart('') : Args(1) { }
> 
> This setup generates these chained actions:
> /auth/company
> /auth/company/123
> /auth/company/123/lot
> /auth/company/123/lot/987
> 
> --Trevor
> 
> Evan Carroll wrote:
>> I have two destinations in my Catalyst app
>>
>> /auth/company/5/lot
>> /auth/company/5/lot/5
>>
>> This works and is often seen in Catalyst apps to achive this effect.
>> sub lot :Chained('/auth/company') :CaptureArgs(1) {
>> sub view_lot :Chained('/auth/company') :PathPart('') :Args(1) {
>>
>> However, I would also expect the below to work; but, it seems it 
>> doesn't. I
>> can only formulate the effect I want the above way. This is
>> unfortunate because if all chained descendants of `lot` utilize a
>> check provided here in the chain, then shouldn't `view_lot` also get
>> to utilize that code? It would certainly be nice to eliminate
>> redundant code here.
>> sub lot :Chained('/auth/company') :CaptureArgs(1) {
>> sub view_lot :Chained('/auth/company/lot') :PathPart('') :Args(0) {
>>
>> I think it is also confusing to those that first encounter it.
>>
>> I always know that I could just call it /view, and be done with it, 
>> but still.
>> /auth/company/5/lot/5/view rather than, /auth/company/5/lot/5
>>
>> But, I just wanted to know what others thought of this.
>>
> 
> _______________________________________________
> 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/



More information about the Catalyst mailing list