Changeset View
Changeset View
Standalone View
Standalone View
swh/web/settings/production.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
""" | """ | ||||
Django production settings for swh-web. | Django production settings for swh-web. | ||||
""" | """ | ||||
Show All 15 Lines | if swh_web_config.get("throttling", {}).get("cache_uri"): | ||||
) | ) | ||||
# Setup support for proxy headers | # Setup support for proxy headers | ||||
USE_X_FORWARDED_HOST = True | USE_X_FORWARDED_HOST = True | ||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") | SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") | ||||
# We're going through seven (or, in that case, 2) proxies thanks to Varnish | # We're going through seven (or, in that case, 2) proxies thanks to Varnish | ||||
REST_FRAMEWORK["NUM_PROXIES"] = 2 | REST_FRAMEWORK["NUM_PROXIES"] = 2 | ||||
anlambert: The config key should keep the name `production_db` for consistency.
Also you should rather… | |||||
Done Inline Actions
right, adapted.
swh-web configuration from django settings. I did not get that part. ardumont: > The config key should keep the name production_db for consistency.
right, adapted.
> Also… | |||||
Not Done Inline Actionsconfig.py can be seen as a specification for swh-web configuration file. Django settings use some of these configuration values but not all so the distinction. anlambert: `config.py` can be seen as a specification for `swh-web` configuration file.
Django settings… | |||||
db_conf = swh_web_config["production_db"] | |||||
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases | |||||
DATABASES = { | DATABASES = { | ||||
"default": { | "default": { | ||||
"ENGINE": "django.db.backends.sqlite3", | "ENGINE": "django.db.backends.postgresql", | ||||
"NAME": swh_web_config["production_db"], | "NAME": db_conf.get("name"), | ||||
"HOST": db_conf.get("host"), | |||||
"PORT": db_conf.get("port"), | |||||
"USER": db_conf.get("user"), | |||||
"PASSWORD": db_conf.get("password"), | |||||
} | } | ||||
} | } | ||||
WEBPACK_LOADER["DEFAULT"]["CACHE"] = True | WEBPACK_LOADER["DEFAULT"]["CACHE"] = True | ||||
Not Done Inline ActionsFor better readability, this should be rewritten to: DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": db_conf.get("name"), "HOST": db_conf.get("host"), "PORT": db_conf.get("port"), "USER": db_conf.get("user"), "PASSWORD": db_conf.get("password"), } } anlambert: For better readability, this should be rewritten to:
```lang=python
DATABASES = {… | |||||
Done Inline Actionsindeed, i shall readapt the deposit with this as well, thanks. ardumont: indeed, i shall readapt the deposit with this as well, thanks. |
The config key should keep the name production_db for consistency.
Also you should rather set default values in config.py as it enables to separate
swh-web configuration from django settings.