We clearly haven't thought about this case. I really wish we could clean up the plugin completely. It still isn't what we want it to be. :(

Could you please open an issue for this?


On Wed, Oct 2, 2013 at 12:47 PM, Marco Pessotto <melmothx@gmail.com> wrote:

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






--
Marco

_______________________________________________
dancer-users mailing list
dancer-users@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users