[Dancer-users] route_cache breaks with multiple parameters

sawyer x xsawyerx at gmail.com
Wed May 19 02:30:25 CEST 2010


Hey Stephane,

On Wed, May 19, 2010 at 12:16 AM, Stéphane <stephane at shimaore.net> wrote:

>   I've opened bug report 57158
>>>
>> Would it be possible for you to sum it up in a test script?
>>
>
> Finally found some time for it.
>
> I attached the test script to the ticket.
>

This has been incredibly helpful, thank you!

It seems like the match() function is matching /name/bob and /name/bill and
changing the parameter of :name to "bill" from "bob".
Since we're working with references here and the cache uses references to
keep track, it means that it affects the cache as well.
When it tries to store "/name/bill" as a new value, it sees that the
reference to "/name/bob" now points to whatever "/name/bill" is suppose to
so it aliases the key of "bill" in the cache to that of "bob".

I'm having a bit of a hard time explaining (but it's 3:30AM so you'll
forgive me). Basically what it means is:
- Cache: "I'm storing Bob now..."
- Route matching: "I see Bill, but it's the same match as with Bob so I'll
just change Bob's parameters to Bill's"
- Cache: "I'm suppose to store Bill now, but since what was Bob is now the
same as Bill, I'll just alias it"
- User: "Get me Bob.. wait... this is Bill!"
- Developers: "Damn it!"

I'll hack on it a bit tomorrow and keep you posted.



> However while writing it I ran into a separate issue (with or without
> route_cache):
>
> # The following works fine
>
> get '/beep1/*'   => sub { "Splat: ".join(',',splat()); };
>
> get '/beep1/*/*' => sub { "Splat: ".join(',',splat()); };
>
> # The following breaks
>
> get '/beep2/:name/*' => sub {
>  "Name: ".params->{name}." splat: ".join(',',splat());
> };
>
>
> So mixing named parameters and splat fails.
> Before I report this (as a separate issue), is this a "supported" way of
> doing things?
>
>
Better report it as a separate issue. Worst case is it won't be fixed if
enough developers think it shouldn't be mixed. Even in that case, changes
will be required at least in the docs to make it clear.

Always good to open an issue. :)

Thanks again,
Sawyer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20100519/01b5dfb4/attachment.htm>


More information about the Dancer-users mailing list