> Yeah, I can see how pattern matching can assist in routing.  I guess
> that what bothers me about requirements is that (a) it looks like
> validation/untainting (which it's not supposed to be), and (b) it puts
> additional matching logic on the right hand side (which in my head is
> sort of for 'match results').
>
> How about this instead?
>
>     :year:(\d{4})/:day:(\d{1,2}/:month:(\d{1,2})
>
> Sure it's ugly, but at least the matching logic is all in one place.
> Plus hopefully its ugliness discourages abuse.  We can even allow multi-
> line commented maps (after a fashion):
>
>
>     ':year:(\d{4})',      # year, e.g. 9008
>     '/',
>     ':day:(\d{1,2}',      # day, e.g. 99
>     '/',
>     ':month:(\d{1,2})',   # month, e.g. 72
>
>                           => {  app => 'Blog'  rm => 'by_date' },
>
> (Hey, when I formatted it like that, I fixed a bug in my sample code!)
>
> And without comments we can get rid of a little bit of line noise:
>
>     ':year:(\d{4})
>     /
>     :day:(\d{1,2}
>     /
>     :month:(\d{1,2})'   => {  app => 'Blog'  rm => 'by_date' },
>
>
> We could try parsing the comments ourselves, but that way leads to
> madness and despair...
>
> > === More about setting "value => undef"
> >
> > Given a pattern like this:
> >
> > ':year/:month/:day'
> >
> > We need to know whether ":month" and ":day" are optional or required. In 
> > other
> > words, should this work?
> >
> > ':year/'
>
> I'm reading that as: should '/1999' work?
>
> My reading is that it shouldn't match (with or without the requirements),
> because it's missing slashes.  However '/1999//' would be ambigous, at
> least without requirements.

Actually, the question is: Should /1999 be matchable by that routing
directive? I would say that provision should be made to allow that.
However, the restriction should be made that 1999//02 (to match all
the 2nd days of the month in 1999) should be banned. If you want to
specify the third place, you have to specify the second place.

> But if the idea is to provide more matching logic to the routing system,
> then maybe a different syntax could be used for optional parameters?
>
>   ':year/?month/?day'

Maybe ... an alternative would be to specify defaults for them and
anything with a default is optional.

Rob

---------------------------------------------------------------------
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]

Reply via email to