Commit 58f05f36 by Calen Pennington

Merge pull request #2840 from ionis-education-group/double-edxmako-startup

Add method to clear mako template lookups
parents 32fd0737 efa8bd67
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
# limitations under the License. # limitations under the License.
LOOKUP = {} LOOKUP = {}
from .paths import add_lookup, lookup_template from .paths import add_lookup, lookup_template, clear_lookups
...@@ -22,6 +22,13 @@ class DynamicTemplateLookup(TemplateLookup): ...@@ -22,6 +22,13 @@ class DynamicTemplateLookup(TemplateLookup):
self.directories.append(os.path.normpath(directory)) 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): def add_lookup(namespace, directory, package=None):
""" """
Adds a new mako template lookup directory to the given namespace. Adds a new mako template lookup directory to the given namespace.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Initialize the mako template lookup Initialize the mako template lookup
""" """
from django.conf import settings from django.conf import settings
from . import add_lookup from . import add_lookup, clear_lookups
def run(): def run():
...@@ -14,5 +14,6 @@ def run(): ...@@ -14,5 +14,6 @@ def run():
""" """
template_locations = settings.MAKO_TEMPLATES template_locations = settings.MAKO_TEMPLATES
for namespace, directories in template_locations.items(): for namespace, directories in template_locations.items():
clear_lookups(namespace)
for directory in directories: for directory in directories:
add_lookup(namespace, directory) add_lookup(namespace, directory)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment