I tracked this down to a "before_template" sub that I have defined: before_template sub { my $tokens = shift; $tokens->{'is_logged_in'} ||= is_logged_in(); $tokens->{'is_secure'} ||= request->secure(); }; If I comment this out everything keeps running across multiple requests (but obviously my app isn't working properly with this stuff missing). I tried to change this to: hook before_template sub { my $tokens = shift; $tokens->{'is_logged_in'} ||= is_logged_in(); $tokens->{'is_secure'} ||= request->secure(); }; But then I can't even start my app.pl: brian@lerris ~/projects/fan/bin$ plackup fan.pl Error while loading fan.pl: something's wrong at /usr/local/lib/perl5/site_perl/5.12.2/Dancer.pm line 126 Compilation failed in require at fan.pl line 5. BEGIN failed--compilation aborted at fan.pl line 5. brian@lerris ~/projects/fan/bin$ This is weird because Dancer.pm line 126 is this: sub hook { Dancer::Hook->new(@_) } I traced the "new" on Dancer::Hook up to Dancer::Object::Singleton::new which croaks in all circumstances (and Dancer::Hook doesn't have its own "new"). sub new { my ($class) = @_; croak "you can't call 'new' on $class, as it's a singleton. Try to call 'instance'"; } However, if I was hitting this I would expect to get the message from "croak" here which I'm not seeing so I must be tracing this wrong. My app.pl (fan.pl) looks like this: #!/usr/local/bin/perl use Dancer; use Fan::Web::Root; use Fan::Web::Forum; dance(); I think there is something weird with the new "hooks" functionality because in an older version of Dancer I was able to run under plackup directly like this (without Shotgun). Any help would be greatly appreciated. Thanks, Brian On Thu, Jun 9, 2011 at 7:34 AM, Brian E. Lozier <brian@massassi.com> wrote:
I've been happily developing my app with plackup like this:
#!/bin/bash
export DBIC_TRACE=1; plackup -L Shotgun -MMoose -MDBIx::Class fan.pl
However, lately I've been working on the css mostly and the Shotgun loader is slow so I just started it like this:
plackup fan.pl
Interestingly, the first request after I start it works, but any subsequent request gives a runtime error like this:
runtime error
Can't use string ("") as a subroutine ref while "strict refs" in use at /usr/local/lib/perl5/site_perl/5.12.2/Dancer/Factory/Hook.pm line 62.
/usr/local/lib/perl5/site_perl/5.12.2/Dancer/Factory/Hook.pm around line 62
59 croak("The hook '$hook_name' doesn't exists"); 60 } 61 62 $_->(@args) foreach @{$self->get_hooks_for($hook_name)}; 63 } 64 65 sub get_hooks_for {
Does this look familiar to anyone? I am not using any of the hook functionality whatsoever. I grepped my entire codebase for the word "hook" and didn't find any instances. I'm digging into Dancer now but figured someone may have seen this before.
Thanks, Brian