diff --git a/swh/web/settings/development.py b/swh/web/settings/development.py index d1f9563b..826038cd 100644 --- a/swh/web/settings/development.py +++ b/swh/web/settings/development.py @@ -1,19 +1,17 @@ # Copyright (C) 2017-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information -# flake8: noqa - """ Django development settings for swh-web. """ -import os +from django.core.cache import cache -from .common import * +from .common import * # noqa +from .common import MIDDLEWARE MIDDLEWARE += ['swh.web.common.middlewares.HtmlPrettifyMiddleware'] -from django.core.cache import cache cache.clear() diff --git a/swh/web/settings/production.py b/swh/web/settings/production.py index 000d7ffa..a98d2fd7 100644 --- a/swh/web/settings/production.py +++ b/swh/web/settings/production.py @@ -1,54 +1,53 @@ # Copyright (C) 2017-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information -# flake8: noqa - """ Django production settings for swh-web. """ -import os - -from .common import * +from .common import * # noqa +from .common import ( + MIDDLEWARE, CACHES, ALLOWED_HOSTS, WEBPACK_LOADER +) from .common import swh_web_config from .common import REST_FRAMEWORK # activate per-site caching if 'GZip' in MIDDLEWARE[0]: MIDDLEWARE.insert(1, 'django.middleware.cache.UpdateCacheMiddleware') else: MIDDLEWARE.insert(0, 'django.middleware.cache.UpdateCacheMiddleware') MIDDLEWARE += ['swh.web.common.middlewares.HtmlMinifyMiddleware', - 'django.middleware.cache.FetchFromCacheMiddleware'] + 'django.middleware.cache.FetchFromCacheMiddleware'] CACHES.update({ 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': swh_web_config['throttling']['cache_uri'], } }) # Setup support for proxy headers USE_X_FORWARDED_HOST = True SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # We're going through seven (or, in that case, 2) proxies thanks to Varnish REST_FRAMEWORK['NUM_PROXIES'] = 2 ALLOWED_HOSTS += [ 'archive.softwareheritage.org', 'base.softwareheritage.org', 'archive.internal.softwareheritage.org', ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': swh_web_config['production_db'], } } WEBPACK_LOADER['DEFAULT']['CACHE'] = True diff --git a/swh/web/settings/tests.py b/swh/web/settings/tests.py index 17f4062c..4a0e0cc3 100644 --- a/swh/web/settings/tests.py +++ b/swh/web/settings/tests.py @@ -1,79 +1,76 @@ # Copyright (C) 2017-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information -# flake8: noqa - """ Django tests settings for swh-web. """ -import os - from swh.web.config import get_config scope1_limiter_rate = 3 scope1_limiter_rate_post = 1 scope2_limiter_rate = 5 scope2_limiter_rate_post = 2 scope3_limiter_rate = 1 scope3_limiter_rate_post = 1 swh_web_config = get_config() swh_web_config.update({ 'debug': False, 'secret_key': 'test', 'throttling': { 'cache_uri': None, 'scopes': { 'swh_api': { 'limiter_rate': { 'default': '60/min' }, 'exempted_networks': ['127.0.0.0/8'] }, 'swh_vault_cooking': { 'limiter_rate': { 'default': '120/h', 'GET': '60/m' }, 'exempted_networks': ['127.0.0.0/8'] }, 'swh_save_origin': { 'limiter_rate': { 'default': '120/h', 'POST': '10/h' }, 'exempted_networks': ['127.0.0.0/8'] }, 'scope1': { 'limiter_rate': { 'default': '%s/min' % scope1_limiter_rate, 'POST': '%s/min' % scope1_limiter_rate_post, } }, 'scope2': { 'limiter_rate': { 'default': '%s/min' % scope2_limiter_rate, 'POST': '%s/min' % scope2_limiter_rate_post } }, 'scope3': { 'limiter_rate': { 'default': '%s/min' % scope3_limiter_rate, 'POST': '%s/min' % scope3_limiter_rate_post }, 'exempted_networks': ['127.0.0.0/8'] } } } }) -from .common import * +from .common import * # noqa +from .common import ALLOWED_HOSTS, LOGGING # noqa ALLOWED_HOSTS += ['testserver'] # Silent DEBUG output when running unit tests LOGGING['handlers']['console']['level'] = 'INFO'