> > From my perspective, with my variety of real-world mapping requirements,
> > allowing '/string/:app/:rm' => { prefix => 'Foo' } is a *minimalist*
> > solution. Believe it or not. :)
>
> I think you mean app and not prefix in that hash. PREFIX is an
> existing option in CGI::Application::Dispatch.
No, I do actually mean prefix. I'm suggesting that each rule be able to
override the default PREFIX. The :app is already determined from the
rule. Here is a slightly less contrived example table followed by some
example URLs and their results:
PREFIX => 'MySite',
TABLE => [
'blog/:rm' => { app => 'Blog' },
'admin/:app/:rm' => { prefix => 'MySite::Admin' }
'get/:path' => { app => 'GetDoc' }
':app/:rm' => { }
],
URL Module Run Mode
--- ------ --------
/blog/show MySite::Blog show
/blog/list MySite::Blog list
/blog MySite::Blog
/admin/users/edit MySite::Admin::Users edit
/admin/users/add MySite::Admin::Users add
/admin/users MySite::Admin::Users
/foo/bar MySite::Foo bar
/get/some/doc.pdf MySite::GetDocument
(params: path=/some/doc.pdf)
/get/other/doc.pdf MySite::GetDocument
(params: path=/other/doc.pdf)
So the default PREFIX is always prepended, unless overridden by a rule.
> Did anyone have any thoughts on moving the variable assignment into
> the hash instead of tacking them onto the TABLE key? I.E.
>
> 'string' => { app=> 'Foo', params=>':app/:rm' }
>
> Does this add clarity so that conflicting dispatch rules are created?
I dunno. I still prefer matches to the left, results to the right.
> It did for me though I'm still not clear to how a missing required
> parameter is handled. (Who handles the error? The run mode or the
> dispatcher?)
Well, that's an argument against, right there. We're not doing input
validation, but rather URI matching. So we don't have "required"
parameters in the validation sense. It's simply that non-matching URIs
don't match.
So while these are duplicates:
'blog/:year/:month?/:day?' => { app => 'Blog' }
'blog/:page' => { app => 'Blog' }
these aren't:
'blog/:year/:month/:day?' => { app => 'Blog' }
'blog/:page' => { app => 'Blog' }
In the second case, /blog/2002/12 matches the first rule, but /blog/2002
matches the second.
Michael
---
Michael Graham <[EMAIL PROTECTED]>
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]