On Sat, Aug 30, 2014 at 8:33 PM, Josh Smeaton <[email protected]>
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 [email protected].
To post to this group, send email to [email protected].
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/CAGdCwBuZf46eTBkmMUzcZPQwxvxNkoZQaJwJLJOpT-9YEgmyCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.