Re: [Catalyst] Chained actions with can't terminate with :PathPart('') ?
Trevors example might overwhelm you a bit if you're not already that familiar with chained. The thing to understand is, every endpoint needs to end with an action that uses Args, every part in the chain CaptureArgs, both might be (0). So in your example you need a middle chain part for lot with two endpoints, one with Args(0) to match just /lot and another one with Args(1) that captures the lot id and matches /lot/5. HTH -- Best regards, Alex Am Freitag, den 07.05.2010, 19:12 +0200 schrieb Evan Carroll: 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. *** T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien Handelsgericht Wien, FN 79340b *** Notice: This e-mail contains information that is confidential and may be privileged. If you are not the intended recipient, please notify the sender and then delete this e-mail immediately. *** ___ List: Catalyst@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/
[Catalyst] Chained actions with can't terminate with :PathPart('') ?
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. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com ___ List: Catalyst@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/
Re: [Catalyst] Chained actions with can't terminate with :PathPart('') ?
On May 7, 2010, at 10:12 AM, 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. Your chain you list in the top doesn't quite make sense. Should view_lot be chained to Lot? If not, the path would be /auth/company/*/* You don't have an end-point attached to 'lot' either, so that chain would never be resolved. -J ___ List: Catalyst@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/
Re: [Catalyst] Chained actions with can't terminate with :PathPart('') ?
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@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/
Re: [Catalyst] Chained actions with can't terminate with :PathPart('') ?
it seems to me that you have companies that have lots. something like this: sub company :Chained('/auth') :CaptureArgs(1) { ... } sub lot :Chained('company') :Args(0) { ... } sub view_lot :Chained('lot') PathPart('') :Args(1) { ... } would suffice, perhaps? On 5/7/2010 1:12 PM, 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@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/
Re: [Catalyst] Chained actions with can't terminate with :PathPart('') ?
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@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/ ___ List: Catalyst@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/