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

LuRsT
  • 3,973
  • 9
  • 39
  • 51
  • 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)`. – dgw Jun 19 '12 at 20:39
  • 1
    It's because ":Regex matches act globally, i.e. without reference to the namespace from which they are called." http://search.cpan.org/~zarquon/Catalyst-Manual-5.9004/lib/Catalyst/Manual/Intro.pod :( – LuRsT Jun 20 '12 at 16:07

2 Answers2

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?

James Green
  • 1,693
  • 11
  • 18
-1

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

Cafe
  • 104
  • 1
  • 3