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

Add method to clear mako template lookups
This commit is contained in:
Calen Pennington
2014-03-18 14:31:13 -04:00
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)