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).
This commit is contained in:
Bertrand Marron
2014-03-06 17:04:51 +01:00
parent d1442e7b2a
commit efa8bd6755
3 changed files with 10 additions and 2 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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)