[Catalyst] URL mapping relative to Controller name space.

Bill Moseley moseley at hank.org
Sat Jul 30 21:02:20 CEST 2005


On Sat, Jul 30, 2005 at 01:46:05PM -0400, David Storrs wrote:
> Would this do what you want? (untested):
> 
>     package App::C::<WHATEVER>;
> 
>     sub table_dispatcher : Regex('^admin/crud/([\w/]*)') {

Yes and no.  Maybe I'm stuck on thinking about Local too much.
But, your example is kind of what I was trying to avoid -- having code
inside the controller know anything about where it's located.

I'm trying to write a controller that's based on where it's placed in
the lib/App/C hierarchy and doesn't require any changes to the
controller if it's moved.

    mv C/Admin/Crud.pm C/Other/Foo/Bar/Bla.pm

and now the URLs been remapped.  (Except the "package" needs to be
updated -- too bad that's even needed as we can infer the package name
from where the file is located.)

"Local" actions solve this, although then I've got an extra path
segment that doesn't convey any information.  Well, that's not true if
I move to the common method of listing the actions before the table
name.

I guess I'll just have to conform.  ;)

-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list