On 29 août 2014, at 01:33, Tim Graham <[email protected]> wrote:

> There have been some other movements to consolidate settings into a dict 
> (e.g. #22734 for email settings) so it seems like we prefer this approach 
> despite the drawbacks.

Indeed, I've noticed that grouping settings that share a common prefix in a 
dict is often less convenient.

Advantages are limited:

- It improves the structure of the documentation.
- It ensures that related settings remain grouped together.
- It satisfies our craving for DRY.
- It artificially lowers len(dir(django.conf.global_settings)).

The two last items have especially little value.

The main drawback is that t's much less practical to change a single value in 
that very common use case:

    # myproject/settings/prod.py
    from . base import *
    FOO['BAR'] = 'baz'

If base.py doesn't define FOO, you have to copy or import the default value 
from django.conf.global_settings. If it does, you can override some keys as 
shown above, but FOO_BAR = 'baz' is still easier.

If it weren't for backwards compatibility, we could recursively merge dicts 
from user settings into defaults settings. For example 
https://github.com/django/django/pull/3138 achieves that in override_settings.

To me that PR looks like "let's fix the problem for ourselves in the test suite 
and leave it for our users" :-/ If it's inconvenient to alter settings in 
tests, it's just as inconvenient to combine them in projets that have several 
settings modules.

EDIT: the PR has been merged while I was writing this email. I need to think 
and type faster :-)

Considering how many settings we've turned into dicts, I'm wondering if we 
should accept the consequences and implement the merging behavior. We'd have to 
make sure that setting a key to None is equivalent to not providing it at all. 
We could take this opportunity to review default values for settings, as we've 
already done in a few specific cases.

Do you think we could accept that level of backwards incompatibility ?

-- 
Aymeric.




-- 
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/6B358ABA-337C-4D62-9B2E-005219C183F9%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to