Two or more PathParts chained ( Catalyst )
Asked Answered
D

2

7

How can I have more than one pathpart in an action at the same time? I tried with Regex and LocalRegex but it realy doesnt work.

This is the result I want:

/typeone/*/*/something
/typetwo/*/*/something

I want to achieve this by using only one base action that captures the two args in from, and can have either the "typeone" or "typetwo" pathpart.

The "something" is just another action that is chained to that base. I don't want to have two bases with two different pathparts, that would require me to have two something chained to each of the bases, right?

Thank you

Dorty answered 19/6, 2012 at 16:33 Comment(2)
Ok, after trying a bit, either chaining or regex work but not both in combination. I tried sub anchor :Chained :Regex('^type(one|two)$') :CaptureArgs(2) {} ... sub something :Chained('anchor') :Args(0) {}. Maybe its because Regex is consuming all three parts instead of honoring the CaptureArgs(2).Counterproposal
It's because ":Regex matches act globally, i.e. without reference to the namespace from which they are called." search.cpan.org/~zarquon/Catalyst-Manual-5.9004/lib/Catalyst/… :(Dorty
H
1

The common wisdom in the Catalyst community seems to be that chaining is always a better idea than regex matching, these days -- to the extent that some of the regex stuff might get moved out of core in version 6.

Do the examples here help? http://wiki.catalystframework.org/wiki/gettingstarted/howtos/chainedexamples.view
The account/org/*/edit one seems to involve matching 3 separate PathParts...

Each of the relevant subs -- the ones triggered by typeone and typetwo, in your case -- will be run. Or is that not what you're after?

Heliacal answered 2/7, 2013 at 0:42 Comment(0)
F
-1

As far as I know, there is no way to set more then one PathPart, or to have a regexp-enabled PathPart.

Frenchify answered 29/9, 2012 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.