[dancer-users] Plugin nesting in Dancer2

Marco Pessotto melmothx at gmail.com
Wed Oct 2 11:47:39 BST 2013


Hello all!

I have a question about the plugin nesting in Dancer2. I'd like to know
if using a plugin (notably the Dancer2::Plugin::Database) inside another
plugin is doable or deprecated or hacky or unsupported or just can't
work.

This used to work with Dancer1, but now it's unclear if and how it
should work, as we don't do "use Dancer qw/:syntax/" anymore.

The app at runtime seems to work, I get the expected output of the
dumped D2::P::D object, but in a Dancer2 qw/:script/ it fails with a
"deep recursion" error.

use Dancer2 ":script";
use Dancer2::Plugin::Test;
print to_dumper(hello);

perl -I lib t/script.t
1..1
DEPRECATED: Dancer2::Plugin::Test calls 'dsl' instead of '$dsl->dsl'. at /home/melmoth/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Dancer2/Plugin/Database.pm line 57.
DEPRECATED: Dancer2::Plugin::Test calls 'dsl' instead of '$dsl->dsl'. at /tmp/MyApp/lib/Dancer2/Plugin/Test.pm line 6.
DEPRECATED: Dancer2::Plugin::Test calls 'dsl' instead of '$dsl->dsl'. at /tmp/MyApp/lib/Dancer2/Plugin/Test.pm line 6.
DEPRECATED: Dancer2::Plugin::Test calls 'dsl' instead of '$dsl->dsl'. at /tmp/MyApp/lib/Dancer2/Plugin/Test.pm line 6.
DEPRECATED: Dancer2::Plugin::Test calls 'dsl' instead of '$dsl->dsl'. at /tmp/MyApp/lib/Dancer2/Plugin/Test.pm line 6.
DEPRECATED: Dancer2::Plugin::Test calls 'dsl' instead of '$dsl->dsl'. at /tmp/MyApp/lib/Dancer2/Plugin/Test.pm line 6.
Deep recursion on anonymous subroutine at /home/melmoth/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Dancer2/Core/Role/DSL.pm line 72.
# Looks like your test exited with 255 before it could output anything.

The test app is the following (also packed in the tarball attached with
the tests).

conf:
### cut ####
plugins:
    Database:
        driver: SQLite
        database: 'foo.sqlite'
### cut ####

app:

### cut ####

package MyApp;
use strict;
use warnings;
use Dancer2;
use Dancer2::Plugin::Test;

our $VERSION = '0.1';

get '/' => sub {
    my $dbh = hello;
    return to_dumper($dbh);
};

true;

### cut ####

plugin:

### cut ####
package Dancer2::Plugin::Test;
use strict;
use warnings;

use Dancer2::Plugin;
use Dancer2::Plugin::Database;

register hello => sub {
    my $dsl     = shift;
    return database;
};

register_plugin;
1;
### cut ####

Thanks in advance

Best wishes


-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyApp.tar.gz
Type: application/octet-stream
Size: 1310 bytes
Desc: test app
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20131002/8f7f0b5a/attachment.obj>
-------------- next part --------------



-- 
Marco


More information about the dancer-users mailing list