-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternative approach to settings bootstrap #10
Comments
@jmurty: Tai indicated that a bunch of the changes to the settings system were a by-product of your input. Do you have thoughts here? |
To clarify
I meant that they were made in response to issues that you had raised. |
I had a go at rewriting
I think it's probably not worth it, although what I attempted is a little different than what @markfinger has suggested (vanilla imports)... I do still think that using For example, you can't have a These are the reasons why we moved away from vanilla imports to I'd like And there's nothing stopping us from ignoring I'm currently more inclined to:
|
How about we move the split-settings imports into the project's settings. Eg: # At the top of project_settings.py
from split_settings.tools import include
include(
'ixc_django_docker.settings.base',
'ixc_django_docker.settings.compressor',
'ixc_django_docker.settings.logentries',
'ixc_django_docker.settings.storages',
'ixc_django_docker.settings.whitenoise',
)
# project settings continue from here... |
@markfinger that's what I tried, but you don't pass module named you pass file paths, and we need some extra logic to include dotenv or override settings (develop, test, staging, production), and we either lose the (I think) useful printout of what's actually being imported OR end up with a tonne of messy boilerplate in project settings... import os
from split_settings.tools import include, optional
import ixc_django_docker.settings
# Directory containing ixc-django-docker settings modules.
IXC_DJANGO_DOCKER_SETTINGS_DIR = \
os.path.dirname(ixc_django_docker.settings.__file__)
# Directory containing project settings modules.
PROJECT_SETTINGS_DIR = os.path.dirname(__file__)
# Settings file to include from both ixc-django-docker and project settings
# directories.
OVERRIDE_SETTINGS = os.environ.get('OVERRIDE_SETTINGS') or \
'%s.py' % os.environ['DOTENV']
# Include `ixc-django-docker` settings.
include(os.path.join(IXC_DJANGO_DOCKER_SETTINGS_DIR, s) for s in (
'base.py',
# 'celery.py',
# 'celery_email.py',
'compressor.py',
# 'extensions.py',
# 'haystack.py',
'logentries.py',
# 'master_password.py',
# 'nose.py',
# 'post_office.py',
# 'redis_cache.py',
# 'sentry.py',
'storages.py',
'whitenoise.py',
))
# Include `ixc-django-docker` override settings.
include(optional(
os.path.join(IXC_DJANGO_DOCKER_SETTINGS_DIR, OVERRIDE_SETTINGS)))
# Include project settings OR replace with your actual project settings.
include(os.path.join(PROJECT_DIR, s) for s in (
'base.py',
'foo.py',
))
# Include project override settings.
include(optional(os.path.join(PROJECT_SETTINGS_DIR, s)) for s in (
OVERRIDE_SETTINGS,
'local.py'
)) Is this really any better than just having a comment that points you to docs or a diagram or Like I said, there's absolutely nothing stopping you from implementing exactly this (or something else) in your project without making any change to But I think that it's important for But, I do think I can make it do a better job in looking for local overrides when given a Python module instead of a Python package as |
Nah, that's fair enough. We've attempted the easy workarounds, and it seems like none are viable. I'm happy to roll with things |
@markfinger Here's where I've tried to explain simply how to configure the settings that get included: https://github.com/ixc/ixc-django-docker/blob/6d7191679fe26a42871050d84d6f790087015a4a/README.rst#about-settings-modules Would linking to this have been better than linking to |
I don't have much to add here. My only other thought about how to make the settings less opaque from within a project would be to have a more explicit project settings file template in But I am tending towards trying to solve the inherent complexity of the settings with clear and easily-found documentation, rather than shifting it around. I don't think there is a way to eliminate it, just hide it more or less well. |
A good starting point for documenting the settings might be a relatively simple table describing each setting module/file, what it does, and the settings you might most often need to tweak with clear guidance on where to apply the tweak (before or after the default settings are loaded) |
Yeah, sounds good. |
Rather than using split-settings to load a bunch of settings files, can we simply import the
project_settings.py
file which will explicitly name the settings modules imported?The primary goal is reducing the magic so that we can get a more easily understandable ramp-up for new developers.
Also secondary benefits of making it easier for IDEs to jump to the settings file.
The text was updated successfully, but these errors were encountered: