diff --git a/common/djangoapps/edxmako/__init__.py b/common/djangoapps/edxmako/__init__.py index 613342b35a..981d640bc0 100644 --- a/common/djangoapps/edxmako/__init__.py +++ b/common/djangoapps/edxmako/__init__.py @@ -13,4 +13,4 @@ # limitations under the License. LOOKUP = {} -from .paths import add_lookup, lookup_template +from .paths import add_lookup, lookup_template, clear_lookups diff --git a/common/djangoapps/edxmako/paths.py b/common/djangoapps/edxmako/paths.py index 8601110ddd..a29a68e8b3 100644 --- a/common/djangoapps/edxmako/paths.py +++ b/common/djangoapps/edxmako/paths.py @@ -22,6 +22,13 @@ class DynamicTemplateLookup(TemplateLookup): self.directories.append(os.path.normpath(directory)) +def clear_lookups(namespace): + """ + Remove mako template lookups for the given namespace. + """ + if namespace in LOOKUP: + del LOOKUP[namespace] + def add_lookup(namespace, directory, package=None): """ Adds a new mako template lookup directory to the given namespace. diff --git a/common/djangoapps/edxmako/startup.py b/common/djangoapps/edxmako/startup.py index 2ecc8b231e..7d291b4bc0 100644 --- a/common/djangoapps/edxmako/startup.py +++ b/common/djangoapps/edxmako/startup.py @@ -2,7 +2,7 @@ Initialize the mako template lookup """ from django.conf import settings -from . import add_lookup +from . import add_lookup, clear_lookups def run(): @@ -14,5 +14,6 @@ def run(): """ template_locations = settings.MAKO_TEMPLATES for namespace, directories in template_locations.items(): + clear_lookups(namespace) for directory in directories: add_lookup(namespace, directory)