PerlDancer/Dancer2-Plugin-Auth-Tiny

Route exception: Hook 'database_connected' does not exist

Opened this issue · 3 comments

I have in my app
use Dancer2; #(0.159002)
use Dancer2::Session::Cookie #(0.006)
use Dancer2::Plugin::Database #(2.12)
and after I tried to use
use Dancer2::Plugin::Auth::Tiny #(0.005)
I'v got an error

Entering hook core.app.before_request in /usr/local/share/perl/5.18.2/Dancer2/Core/App.pm l. 1245
DEPRECATED: Dancer2::Plugin::Database calls 'dsl' instead of '$dsl->dsl'. at /usr/local/share/perl/5.18.2/Dancer2/Plugin/Database.pm line 31.
[appname:23812] debug @2015-03-13 13:11:37> Adding pg_enable_utf8 to DBI connection params to enable UTF-8 support in /usr/local/share/perl/5.18.2/Dancer/Plugin/Database/Core.pm l. 108
[appname:23812] error @2015-03-13 13:11:37> Route exception: Hook 'database_connected' does not exist at /usr/local/share/perl/5.18.2/Dancer2/Plugin/Database.pm line 45. in /usr/share/perl5/Return/MultiLevel.pm l. 54

is it a problem with P::A::T or P::Database ?

On Fri, 13 Mar 2015, neiromancer wrote:

I have in my app
use Dancer2; #(0.159002)
use Dancer2::Session::Cookie #(0.006)
use Dancer2::Plugin::Database #(2.12)
and after I tried to use
use Dancer2::Plugin::Auth::Tiny #(0.005)
I'v got an error

Entering hook core.app.before_request in /usr/local/share/perl/5.18.2/Dancer2/Core/App.pm l. 1245
DEPRECATED: Dancer2::Plugin::Database calls 'dsl' instead of '$dsl->dsl'. at /usr/local/share/perl/5.18.2/Dancer2/Plugin/Database.pm line 31.
[appname:23812] debug @2015-03-13 13:11:37> Adding pg_enable_utf8 to DBI connection params to enable UTF-8 support in
/usr/local/share/perl/5.18.2/Dancer/Plugin/Database/Core.pm l. 108
[appname:23812] error @2015-03-13 13:11:37> Route exception: Hook 'database_connected' does not exist at /usr/local/share/perl/5.18.2/Dancer2/Plugin/Database.pm line 45. in
/usr/share/perl5/Return/MultiLevel.pm l. 54

is it a problem with P::A::T or P::Database ?

A part of the problem is calling plugin_setting
in the wrong place in Dancer2::Plugin::Database

plugin_setting should be called in a on_plugin_import block.

my $settings = {};

on_plugin_import {
$settings = plugin_setting()
unless $settings->{'charset'};
$settings->{'charset'} ||= config->{'charset'} || 'UTF-8';
};

sub _load_db_settings should be removed from Dancer2::Plugin::Database.

I didn't got the time to test this...

Regards,
Henk van Oers

I'm tripping on this too, I created an issue for this in D1::P::Database:

bigpresh/Dancer-Plugin-Database#62

I did the change suggest ed above and am still getting it :(