settings: Group {default,prod,dev}_settings as configured_settings.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-06-07 18:44:48 -07:00 committed by Tim Abbott
parent 18eba18df7
commit c45962785c
4 changed files with 35 additions and 23 deletions

View File

@ -69,11 +69,14 @@ In a production environment, we have:
`zproject/settings.py`.
* `zproject/settings.py` is the main Django settings file for Zulip.
It contains all the settings that are constant for all Zulip
It imports everything from `zproject/configured_settings.py`, and
contains all the settings that are constant for all Zulip
installations (e.g. configuration for logging, static assets,
middleware, etc.). It has a line `from prod_settings
import *`, which in a prod environment has the effect of importing
`/etc/zulip/settings.py` (via a symlink).
middleware, etc.).
* `zproject/configured_settings.py` imports everything from
`zproject/default_settings.py`, then in a prod environment imports
`/etc/zulip/settings.py` via a symlink.
* `zproject/default_settings.py` has the default values for the settings the
user would set in `/etc/zulip/settings.py`.

View File

@ -21,6 +21,7 @@ def check_pyflakes(files: List[str], options: argparse.Namespace) -> bool:
("settings.py", "settings import *' used; unable to detect undefined names"),
("settings.py", "may be undefined, or defined from star imports"),
("settings.py", "settings.*' imported but unused"),
# Sphinx adds `tags` specially to the environment when running conf.py.
("docs/conf.py", "undefined name 'tags'"),

View File

@ -0,0 +1,16 @@
########################################################################
# DEFAULT VALUES FOR SETTINGS
########################################################################
# For any settings that are not set in the site-specific configuration file
# (/etc/zulip/settings.py in production, or dev_settings.py or test_settings.py
# in dev and test), we want to initialize them to sane defaults.
from .default_settings import * # isort: skip
# Import variables like secrets from the prod_settings file
# Import prod_settings after determining the deployment/machine type
from .config import PRODUCTION
if PRODUCTION:
from .prod_settings import * # isort: skip
else:
from .dev_settings import * # isort: skip

View File

@ -2,14 +2,22 @@
########################################################################
# Here's how settings for the Zulip project work:
#
# * configured_settings.py imports default_settings.py, which contains
# default values for settings configurable in prod_settings.py.
#
# * configured_settings.py imports prod_settings.py, and any site-specific
# configuration belongs there. The template for prod_settings.py is
# prod_settings_template.py.
#
# * settings.py contains non-site-specific and settings configuration
# for the Zulip Django app.
# * settings.py imports prod_settings.py, and any site-specific configuration
# belongs there. The template for prod_settings.py is prod_settings_template.py
# for the Zulip Django app.
#
# See https://zulip.readthedocs.io/en/latest/subsystems/settings.html for more information
#
########################################################################
from .configured_settings import * # isort: skip
from copy import deepcopy
import os
import time
@ -81,22 +89,6 @@ GENERATE_STRIPE_FIXTURES = False
# process /etc/boto.cfg.
os.environ['BOTO_CONFIG'] = '/etc/zulip/boto.cfg'
########################################################################
# DEFAULT VALUES FOR SETTINGS
########################################################################
# For any settings that are not set in the site-specific configuration file
# (/etc/zulip/settings.py in production, or dev_settings.py or test_settings.py
# in dev and test), we want to initialize them to sane defaults.
from .default_settings import *
# Import variables like secrets from the prod_settings file
# Import prod_settings after determining the deployment/machine type
if PRODUCTION:
from .prod_settings import *
else:
from .dev_settings import *
# These are the settings that we will check that the user has filled in for
# production deployments before starting the app. It consists of a series
# of pairs of (setting name, default value that it must be changed from)