The way the discussion has gone, I think I favor individual settings over 
settings grouped in a dictionary in this case.

If we drop magical merging of dictionary settings (which seems like it will 
cause more confusion), a user's options for customizing a single key in 
settings are:
1. Redefine the entire dictionary in a project's settings
2. Use the following pattern to update a subset of keys:

from django.conf.global_settings import SECURITY_MIDDLEWARE

SECURITY_MIDDLEWARE.update({
    'SSL_HOST': 'staging.my.host.com',
})

We have admonitions in the docs that users should not import from 
global_settings and I don't care for 1 either.

On Saturday, August 30, 2014 8:58:17 PM UTC-4, Michael Manfre wrote:
>
>
>
>
> On Sat, Aug 30, 2014 at 8:33 PM, Josh Smeaton <josh.s...@gmail.com 
> <javascript:>> wrote:
>>
>> I think the problem becomes more pronounced when you want to override a 
>> single sub-setting between your different environments:
>>
>> # base.py
>>
>> SECURITY_MIDDLEWARE = {
>>     'HSTS_SECONDS': 10,
>>     'HSTS_INCLUDE_SUBDOMAINS': True,
>>     'CONTENT_TYPE_NOSNIFF': True,
>>     'BROWSER_XSS_FILTER': True,
>>     'SSL_REDIRECT': False,
>>     'SSL_HOST': 'prod.my.host.com',
>> }
>>
>>  
>>
>> #staging.py
>>
>> from base import * 
>>
>>  
>>
>> SECURITY_MIDDLEWARE = {
>>     'SSL_HOST': 'staging.my.host.com',
>> }
>>
>>
>> Does staging now represent the merged dicts of base and staging, or the 
>> merged dicts of default and staging? I believe, with the merged dict 
>> implementation, it is the merge of staging and default. Now if all of the 
>> settings were their own setting rather than an entry in a dict, I'd just 
>> set the single setting I'd need to change, and be done with it.
>>
>> There are very little gains to using a dict, and I would argue it harms 
>> readability and the use of settings in general unless it's actually 
>> required.
>>
>
> Auto merging dicts is the wrong approach. Staging.py should contain 
> exactly what it appears to contain, SECURITY_MIDDLEWARE with a single key 
> defined. If some one needs to tweak one of the values, they should use 
> dict's update. This is the same behavior that is required for DATABASES and 
> the other existing dict settings.
>
> SECURITY_MIDDLEWARE.update({
>     'SSL_HOST': 'staging.my.host.com',
> })
>
> Regards,
> Michael Manfre
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/189765f6-1db6-4eee-b2a4-3d9626e45d7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to