Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
5d39b0ce
Commit
5d39b0ce
authored
Jun 15, 2015
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make edxmako cache properly with changing lookup paths
parent
fa4dcdeb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
common/djangoapps/edxmako/paths.py
+18
-0
No files found.
common/djangoapps/edxmako/paths.py
View file @
5d39b0ce
"""
Set up lookup paths for mako templates.
"""
import
hashlib
import
os
import
pkg_resources
...
...
@@ -15,6 +17,10 @@ class DynamicTemplateLookup(TemplateLookup):
A specialization of the standard mako `TemplateLookup` class which allows
for adding directories progressively.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
DynamicTemplateLookup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
__original_module_directory
=
self
.
template_args
[
'module_directory'
]
def
add_directory
(
self
,
directory
,
prepend
=
False
):
"""
Add a new directory to the template lookup path.
...
...
@@ -24,6 +30,18 @@ class DynamicTemplateLookup(TemplateLookup):
else
:
self
.
directories
.
append
(
os
.
path
.
normpath
(
directory
))
# Since the lookup path has changed, the compiled modules might be
# wrong because now "foo.html" might be a completely different template,
# and "foo.html.py" in the module directory has no way to know that.
# Update the module_directory argument to point to a directory
# specifically for this lookup path.
unique
=
hashlib
.
md5
(
":"
.
join
(
str
(
d
)
for
d
in
self
.
directories
))
.
hexdigest
()
self
.
template_args
[
'module_directory'
]
=
os
.
path
.
join
(
self
.
__original_module_directory
,
unique
)
# Also clear the internal caches. Ick.
self
.
_collection
.
clear
()
self
.
_uri_cache
.
clear
()
def
clear_lookups
(
namespace
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment