On 09/16/2016 11:56 AM, Nik Mitev wrote:
> On 16/09/16 10:31, Stefan Hornburg (Racke) wrote:
>> On 09/16/2016 11:27 AM, Nik Mitev wrote:
>>> Hi,
>>>
>>> A quick update, to make sure no one wastes time answering my initial 
>>> question...
>>> Location of the config file is not the issue - within my main app file 
>>> (where the routes are defined), the config hash
>>> contains all of the configuration, and the config.yml location. In a plugin 
>>> I wrote however a part of the configuration
>>> is missing - not even all of it.
>>> All that's left is for me to figure out why :)
>>>
>>> Nik
>> Hello Nik,
>>
>> maybe you can share the code of the plugin - so we might spot the problem in 
>> there.
>>
>>
> I narrowed it down further (I think). Here is the beginning of the code:
> 
> package Dancer2::Plugin::ESS2::Auth;
> use strict;
> ... snip use statements ...
> use Dancer2::Plugin;
> 
> register ess2_check_user => sub {
>     my $dsl = shift;
>     my %db_info = %{$dsl->config->{'db_info'}};
> 
> ... snip ...
> };
> 
> .... more register statements ...
> register_plugin;
> 1;
> 
> If I edit the above to
> 
>     my $dsl = shift;
> + print Dumper $dsl;
> 
> I get all the information I would expect to be under the config key, e.g.
> 'config' => {
>                       'plugins' => {
>                                              'ESS2::Auth' => {
>                                                                        
>     all the data from the plugin config
>                                                                         },
>                                            },
>                      'db_info' => {
>                                             the database connection settings
>                                           },
> etc ...
>                    },
> 
> Dumping $dsl->config however returns only the contents of
> $dsl->config->{'plugins'}->{'ESS2::Auth'}
> when I would expect it to return the 'plugins' key and the 'db_info' key
> and the rest of it.
> 
> Thanks for any and all input :)

You need to ask for the plugin config, e.g. with plugin_setting keyword.

A nicer way is to use an accessor in your plugin:

https://metacpan.org/pod/Dancer2::Plugin#Getting-default-values-from-config-file

Regards
        Racke



-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to