From ba07dec4c511fd193903f371bda2ad005892ff58 Mon Sep 17 00:00:00 2001 From: John Eskew Date: Wed, 1 Nov 2017 16:52:21 -0400 Subject: [PATCH] Move edxmako startup to AppConfig::ready. --- cms/envs/common.py | 2 +- common/djangoapps/edxmako/apps.py | 22 ++++++++++++++++++++++ common/djangoapps/edxmako/startup.py | 20 -------------------- lms/envs/common.py | 2 +- 4 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 common/djangoapps/edxmako/apps.py delete mode 100644 common/djangoapps/edxmako/startup.py diff --git a/cms/envs/common.py b/cms/envs/common.py index 07c31719ed..eccf5b07ca 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -965,7 +965,7 @@ INSTALLED_APPS = [ 'openedx.core.djangoapps.datadog', # For asset pipelining - 'edxmako', + 'edxmako.apps.EdxMakoConfig', 'pipeline', 'static_replace', 'require', diff --git a/common/djangoapps/edxmako/apps.py b/common/djangoapps/edxmako/apps.py new file mode 100644 index 0000000000..3cf4130924 --- /dev/null +++ b/common/djangoapps/edxmako/apps.py @@ -0,0 +1,22 @@ + +from django.apps import AppConfig +from django.conf import settings +from . import add_lookup, clear_lookups + + +class EdxMakoConfig(AppConfig): + name = 'edxmako' + verbose_name = "edX Mako Templating" + + def ready(self): + """ + Setup mako lookup directories. + + IMPORTANT: This method can be called multiple times during application startup. Any changes to this method + must be safe for multiple callers during startup phase. + """ + template_locations = settings.MAKO_TEMPLATES + for namespace, directories in template_locations.items(): + clear_lookups(namespace) + for directory in directories: + add_lookup(namespace, directory) diff --git a/common/djangoapps/edxmako/startup.py b/common/djangoapps/edxmako/startup.py deleted file mode 100644 index 4fc94a1024..0000000000 --- a/common/djangoapps/edxmako/startup.py +++ /dev/null @@ -1,20 +0,0 @@ -""" -Initialize the mako template lookup -""" -from django.conf import settings - -from . import add_lookup, clear_lookups - - -def run(): - """ - Setup mako lookup directories. - - IMPORTANT: This method can be called multiple times during application startup. Any changes to this method - must be safe for multiple callers during startup phase. - """ - template_locations = settings.MAKO_TEMPLATES - for namespace, directories in template_locations.items(): - clear_lookups(namespace) - for directory in directories: - add_lookup(namespace, directory) diff --git a/lms/envs/common.py b/lms/envs/common.py index ae9079993d..5b5799f728 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2039,7 +2039,7 @@ INSTALLED_APPS = [ 'status', # For asset pipelining - 'edxmako', + 'edxmako.apps.EdxMakoConfig', 'pipeline', 'static_replace', 'webpack_loader',