Skip to content

Commit 33f571d

Browse files
committed
fix: catch STORAGES staticfiles and log in common settings
1 parent 95fcf90 commit 33f571d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

eox_theming/settings/common.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
from __future__ import unicode_literals
1212

13+
import logging
14+
15+
logger = logging.getLogger(__name__)
16+
1317
# Quick-start development settings - unsuitable for production
1418
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
1519

@@ -51,8 +55,7 @@ def plugin_settings(settings):
5155
try:
5256
settings.TEMPLATES[0]['OPTIONS']['loaders'][0] = 'eox_theming.theming.template_loaders.EoxThemeTemplateLoader'
5357
except (AttributeError, TypeError):
54-
# We must find a way to register this error
55-
pass
58+
logger.error("Couldn't set template loaders. Check your settings.")
5659

5760
try:
5861
eox_configuration_path = 'eox_theming.theming.context_processor.eox_configuration'
@@ -63,17 +66,20 @@ def plugin_settings(settings):
6366

6467
settings.DEFAULT_TEMPLATE_ENGINE = settings.TEMPLATES[0]
6568
except (AttributeError, TypeError):
66-
# We must find a way to register this error
67-
pass
69+
logger.error("Couldn't set default template engine. Check your settings.")
6870

6971
try:
7072
settings.MIDDLEWARE = [
7173
'eox_theming.theming.middleware.EoxThemeMiddleware' if 'CurrentSiteThemeMiddleware' in x else x
7274
for x in settings.MIDDLEWARE
7375
]
7476
except (AttributeError, TypeError):
75-
# We must find a way to register this error.
76-
pass
77+
logger.error("Couldn't set MIDDLEWARE. Check your settings.")
78+
79+
try:
80+
settings.STORAGES['staticfiles']['BACKEND'] = 'eox_theming.theming.storage.EoxProductionStorage'
81+
except Exception: # pylint: disable=broad-except
82+
logger.error("Couldn't set EoxThemeStorage as staticfiles storage backend. Check your settings.")
7783

7884
settings.EOX_THEMING_DEFAULT_THEME_NAME = 'bragi'
7985

@@ -93,10 +99,4 @@ def plugin_settings(settings):
9399
settings.EOX_THEMING_CONFIGURATION_HELPER_BACKEND = 'eox_theming.edxapp_wrapper.backends.j_configuration_helpers'
94100
settings.EOX_THEMING_THEMING_HELPER_BACKEND = 'eox_theming.edxapp_wrapper.backends.j_theming_helpers'
95101
settings.EOX_THEMING_STORAGE_BACKEND = 'eox_theming.edxapp_wrapper.backends.l_storage'
96-
97-
if not hasattr(settings, 'STORAGES'):
98-
settings.STORAGES = {}
99-
100-
settings.STORAGES.setdefault('staticfiles', {})['BACKEND'] = 'eox_theming.theming.storage.EoxProductionStorage'
101-
102102
settings.EOX_THEMING_EDXMAKO_BACKEND = 'eox_theming.edxapp_wrapper.backends.l_mako'

0 commit comments

Comments
 (0)