-1 on using dictionaries to group somewhat related settings. Dicts make it
much harder to override specific keys - and implementing a dict merge to
get around a problem that we're creating ourselves for reasons
of perceived attractiveness seems a little backwards. Mergingi
If I want to simply override one key:
SECURITY_MIDDLEWARE = {
'HSTS_SECONDS': 10,
}
vs
SECURITY_MIDDLEWARE_HSTS_SECONDS = 10
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.
>
>
--
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/e336dcca-0a06-4a98-a4e8-ee5beff6c3e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.