[Dancer-users] Runtime error having to do with hooks (which I don't use)

Brian E. Lozier brian at massassi.com
Fri Jun 10 01:30:57 CEST 2011


On Thu, Jun 9, 2011 at 12:12 PM, Brian E. Lozier <brian at massassi.com> wrote:
> On Thu, Jun 9, 2011 at 12:11 PM, David Precious <davidp at preshweb.co.uk> wrote:
>> [CC'd list back in]
>> On Thursday 09 June 2011 20:02:27 Brian E. Lozier wrote:
>>> I'm using Dancer-1.3051.  Did you try it under plackup?
>>
>> Yeah, I tried it both by running bin/app.pl directly, and starting it by
>> running plackup bin/app.pl - both worked.
>>
>>> I will try to repro it with a scaffolded app.  In my app I have one before
>>> filter, one before_template filter, one after template filter.
>
> My mistake, I have one before filter, one before_template filter and
> one after filter (not after template).

Well I tracked down one bug that turns out may be a documentation bug.
 I haven't had time to look really really carefully but I was able to
reproduce a crash when just starting app.pl if the "hook" syntax is
wrong.  The docs say you can do this:

hook before_template sub {
 # do something
};

But you really need to do it like this:

hook before_template => sub {
 # do something
};

A bunch of the hook documentation is broken, here's a pasted portion
that shows the error in the docs multiple times.  I'm still trying to
find out the root cause of my original issue (which is why I tried
using the "hook" syntax instead of declaring the before_template
directly).

before

    This is an alias to before.

    This hook receives no arguments.

      before sub {
        ...
      };

    is equivalent to

      hook before sub {
        ...
      };

before_template_render

    This is an alias to 'before_template'.

    This hook receives as argument a HashRef, containing the tokens.

      hook before_template_render sub {
        my $tokens = shift;
        delete $tokens->{user};
      };

    is equivalent to

      hook before_template sub {
        my $tokens = shift;
        delete $tokens->{user};
      };



>
>>
>> Ah, OK - I'll add a before handler and an after_template to my test case and
>> see if that changes anything.
>>
>>
>>> It's odd that
>>> the first request works and every subsequent ones don't work.
>>
>> Indeed.  I suspect it's something like a side-effect of what one of the
>> handlers returned being inadvertently set, or something.
>>
>>
>> --
>> David Precious  ("bigpresh")
>> http://www.preshweb.co.uk/
>>
>>   "Programming is like sex. One mistake and you have to support
>>   it for the rest of your life". (Michael Sinz)
>>
>


More information about the Dancer-users mailing list