[Dancer-users] messed up routes

Richard Huxton dev at archonet.com
Thu Oct 20 20:40:06 CEST 2011


On 20/10/11 17:28, Mr. Puneet Kishor wrote:
>
> On Oct 20, 2011, at 11:22 AM, Richard Huxton wrote:

>> That will end up with whatever layout the previous request set.
>>
>> The layout is *not* per-request (unless you add it to the template
>> call).
>
> Yes, this is the *only* potential problem spot that I could see, and
> I mentioned that in my subsequent email. I have not added a layout
> even to the default route instead of relying on the 'main' layout to
> be picked up automatically.
[snip]
> In other words, I was unable to force an erroneous layout. And then,
> 10 mins later, bam, I requested the default page but it came back
> with the presentation layout. Then I hit Cmd-R 10 times and got the
> presentation layout (wrong layout) and then suddenly, bam, it
> reverted back to the default layout.

If you have more than one backend (e.g. Starman, or a dynamic fastCGI 
setup), then that's quite likely. The best way to see it would be 
something like:

before sub {
     debug "before ($$): layout = ".setting('layout')
         ." path = ".request->path;
};

after sub {
     debug "after ($$): layout = ".setting('layout')
         ." path = ".request->path;
};

That will show you the backend process-id and layout before + after 
rendering. If there's anything funny going on then that's where it is.

> In fact, think this through -- if the above is really true, then once
> the non-default layout has been set (say, 'main_presentation') then
> the default 'main' layout should never be set for anyone because I
> wasn't explicitly setting the main layout. But, that wasn't the case
> as well.

Well, it'll be set if that backend hasn't changed it yet, because that's 
what it defaults to (I assume). But, if you've only got one backend then 
you're correct.

-- 
   Richard Huxton
   Archonet Ltd


More information about the Dancer-users mailing list