[Dancer-users] applying the same setting to different routes in different packages

P Kishor punk.kish at gmail.com
Tue Oct 5 15:22:24 CEST 2010


On Tue, Oct 5, 2010 at 7:53 AM, P Kishor <punk.kish at gmail.com> wrote:
> On Tue, Oct 5, 2010 at 7:46 AM, Alexis Sukrieh <sukria at sukria.net> wrote:
>> Le 05/10/2010 14:32, P Kishor a écrit :
>>
>>> and, I get the following runtime error
>>>
>>> Can't call method "SUPER::opts" on an undefined value at
>>> /Users/punkish/Sites/app/lib/app/app1.pm line 16.
>>
>>
>> The way you call the opts method matters:
>>
>> get '/' => sub {
>>    "forum opts : ".to_yaml(FooApp::Forum->opts());
>> };
>>
>> If you don't call it that way (Class->method) $self is undef, hence your
>> error.
>>
>


even better to call it as __PACKAGE__->opts();

This allows me to reuse that statement in all the sub packages without
having to change the name of the class.

Man, the fewer keystrokes I have to type to make Dancer work means
fewer chances of screwing up. This is getting better and better.

>
> Fantastic! all is well now.
>
> This is really great, and might be worth adding to the cookbook. For
> example, this will also allow me to declare other singletons such as
> $dbh, for a db handle, in one place and the reuse it in other
> packages.
>
> Many thanks.
>
>> --
>> Alexis Sukrieh
>>
>
>
>
> --
> Puneet Kishor
>


More information about the Dancer-users mailing list