abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Primmer" <david.prim...@gmail.com>
Subject Re: Route matching too liberal?
Date Thu, 19 Jun 2008 20:17:09 GMT
This 'route stacking' approach is used in python Routes.
http://routes.groovie.org/manual.html#search-order

What we're experiencing is called "minimization" of routes and happens
when you have ordered routes and the longest ones that you want are
not 'first'. Apparently some devs overlooked the possibility when
stacking their routes.
http://routes.groovie.org/manual.html#minimum-urls

One of the goals of the Routes rewrite in python is to :
Eliminate "minimization gotcha" where an earlier route unexpectedly
matches a URL due to minimization.

http://www.groovie.org/2007/08/29/routes-planning-and-the-road-to-routes-2-0

Here's some rules from the new routes 2 spec:
http://wiki.pylonshq.com/display/routes/Routes+2+Spec
# The path may include variable placeholders like this: "{year}".
These will be returned in the match dict. The value may not contain a
slash. Matching is greedy.
# The path may include wildcard placeholders like this: "{*url}".
These work like variable placeholders except the value may contain
slashes. Matching is greedy. (Or should it be non-greedy?)

Some interesting things they're doing: changing syntax away from the
:varname to {varname} and adding the ability for the route to be used
only for URL generation.

Just some background from a group that is working through these issues
with a larger user base than ours.

davep

On Wed, Jun 18, 2008 at 3:35 PM, ed_ruder <eruder@hi5.com> wrote:
>
> James,
>
> I'm not very familiar with Abdera, but I have browsed the source a bit after
> hitting the same limitation that Jim reported, while working on Shindig. I
> *think* that a simple change in RouteManager could alleviate some (and for
> me, I think, all) of the limitation.
>
> When resolving a route, Rails walks through its routes in the order that
> they are defined. RouteManager walks through the targets.entrySet, which is
> unordered. If RouteManager kept a targets List<> instead of a targets Map<>,
> it could walk through the routes in order. (There would need to be a new
> class defined, to hold both the Route and TargetType, but it would be very
> simple.)
>
> To work around the limitation Jim describes, a client would define a
> /base/:collection/:entry route before the /base/:collection route.
>
> WDYT?
>
> Ed
>
>
> James M Snell wrote:
>>
>> Ruby matching can span segments if a default value for the missing
>> variables is provided.  We, however, don't have default values for our
>> variables.  It would make sense for us to tighten up the matching rules.
>>
>> - James
>>
>> Jim Ancona wrote:
>>> I have run into some problems with my Routes matching unexpectedly.
>>> Before filing a bug, I thought I'd ask for feedback on whether the
>>> current behavior is correct.
>>>
>>> The current algorithm attempts to match the non-variable parts of the
>>> pattern, setting the variable to whatever is in between.
>>>
>>> So the pattern "/base/:collection/" matches both "/base/test/" and
>>> "/base/test/123/". In the second case, the value of the collection
>>> variable is "test/123". In my opinion, not allowing matches to span URI
>>> segments would be less prone to unintuitive results.
>>>
>>> FWIW, a quick glance at some docs on Ruby Routes seems to indicate that
>>> they do not span URI path segments.
>>>
>>> Thoughts?
>>>
>>> Jim
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Route-matching-too-liberal--tp15348853p17993519.html
> Sent from the abdera-dev mailing list archive at Nabble.com.
>
>

Mime
View raw message