Commit efa8bd67 by Bertrand Marron

Add method to clear mako template lookups

Quick and dirty fix (edxapp.startup.run is called twice, once before
loading the configuration, so the paths defined in lms.startup are
basically ignored).
parent d1442e7b
......@@ -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
......@@ -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.
......
......@@ -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)
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