[Dancer-users] Changing config hashref directly (was: Re: Dancer::layout has been deprecated)

Naveed Massjouni naveedm9 at gmail.com
Mon May 23 11:18:23 CEST 2011


On Mon, May 23, 2011 at 5:11 AM, damien krotkine <dkrotkine at gmail.com> wrote:
>
>
> On 22 May 2011 13:46, David Precious <davidp at preshweb.co.uk> wrote:
>>
>> On Saturday 21 May 2011 23:19:18 Naveed Massjouni wrote:
>> > Is config->{layout} = 'foo' the same as set layout => 'foo'?
>>
>> In general, you shouldn't change the hashref returned by config(), but use
>> set() instead.  Some settings, when changed via set(), trigger a hook to
>> handle that change (e.g. initialise a template engine when 'template' is
>> used,
>> set up a catch-all route when 'auto_page' is used, etc).  Changing them
>> directly, bypassing set(), means those triggers won't fire.
>>
>> The 'layout' setting, however, doesn't have any trigger, so changing it
>> directly wouldn't hurt; I still wouldn't recommend it though, for future-
>> proofing.
>>
>> In fact, it might make sense for us to change config() to return a tied
>> hash
>> which emits warnings if you try to change any values, to discourage people
>> from using it to change settings directly, bypassing set().

I'm not sure if I like this. Consider complex user defined
configurations. I like being able to do:
    config->{foo}{bar}{poo} = 42;
Can that even be done via set() ?
-Naveed

>
> That can be a good idea, but we should be extremely cautious with ties :
> they are slow, and a bit magic.
> But a careful implementation can be the perfect solution in this case.
>
>>
>> Cheers
>>
>>
>> --
>> David Precious  ("bigpresh")
>> http://www.preshweb.co.uk/
>>
>>   "Programming is like sex. One mistake and you have to support
>>   it for the rest of your life". (Michael Sinz)
>> _______________________________________________
>> Dancer-users mailing list
>> Dancer-users at perldancer.org
>> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>


More information about the Dancer-users mailing list