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
34db1269
Unverified
Commit
34db1269
authored
Dec 04, 2017
by
Eric Fischer
Committed by
GitHub
Dec 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16601 from edx/efischer/EDU-1731_memoize
Memoize common lookups during request
parents
bcccd488
2e3f871c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletions
+9
-1
common/djangoapps/edxmako/paths.py
+2
-0
openedx/core/djangoapps/theming/helpers.py
+4
-1
openedx/core/djangoapps/theming/tests/test_helpers.py
+3
-0
No files found.
common/djangoapps/edxmako/paths.py
View file @
34db1269
...
@@ -11,6 +11,7 @@ from django.conf import settings
...
@@ -11,6 +11,7 @@ from django.conf import settings
from
mako.exceptions
import
TopLevelLookupException
from
mako.exceptions
import
TopLevelLookupException
from
mako.lookup
import
TemplateLookup
from
mako.lookup
import
TemplateLookup
from
request_cache.middleware
import
request_cached
from
openedx.core.djangoapps.theming.helpers
import
get_template
as
themed_template
from
openedx.core.djangoapps.theming.helpers
import
get_template
as
themed_template
from
openedx.core.djangoapps.theming.helpers
import
get_template_path_with_theme
,
strip_site_theme_templates_path
from
openedx.core.djangoapps.theming.helpers
import
get_template_path_with_theme
,
strip_site_theme_templates_path
...
@@ -107,6 +108,7 @@ def add_lookup(namespace, directory, package=None, prepend=False):
...
@@ -107,6 +108,7 @@ def add_lookup(namespace, directory, package=None, prepend=False):
templates
.
add_directory
(
directory
,
prepend
=
prepend
)
templates
.
add_directory
(
directory
,
prepend
=
prepend
)
@request_cached
def
lookup_template
(
namespace
,
name
):
def
lookup_template
(
namespace
,
name
):
"""
"""
Look up a Mako template by namespace and name.
Look up a Mako template by namespace and name.
...
...
openedx/core/djangoapps/theming/helpers.py
View file @
34db1269
...
@@ -19,14 +19,17 @@ from openedx.core.djangoapps.theming.helpers_dirs import (
...
@@ -19,14 +19,17 @@ from openedx.core.djangoapps.theming.helpers_dirs import (
get_theme_dirs
,
get_theme_dirs
,
get_themes_unchecked
get_themes_unchecked
)
)
from
request_cache.middleware
import
RequestCache
from
request_cache.middleware
import
RequestCache
,
request_cached
logger
=
getLogger
(
__name__
)
# pylint: disable=invalid-name
logger
=
getLogger
(
__name__
)
# pylint: disable=invalid-name
@request_cached
def
get_template_path
(
relative_path
,
**
kwargs
):
def
get_template_path
(
relative_path
,
**
kwargs
):
"""
"""
This is a proxy function to hide microsite_configuration behind comprehensive theming.
This is a proxy function to hide microsite_configuration behind comprehensive theming.
The calculated value is cached for the lifetime of the current request.
"""
"""
# We need to give priority to theming over microsites
# We need to give priority to theming over microsites
# So, we apply microsite override only if there is no associated site theme
# So, we apply microsite override only if there is no associated site theme
...
...
openedx/core/djangoapps/theming/tests/test_helpers.py
View file @
34db1269
...
@@ -12,6 +12,7 @@ from openedx.core.djangoapps.theming import helpers as theming_helpers
...
@@ -12,6 +12,7 @@ from openedx.core.djangoapps.theming import helpers as theming_helpers
from
openedx.core.djangoapps.theming.helpers
import
get_template_path_with_theme
,
strip_site_theme_templates_path
,
\
from
openedx.core.djangoapps.theming.helpers
import
get_template_path_with_theme
,
strip_site_theme_templates_path
,
\
get_themes
,
Theme
,
get_theme_base_dir
get_themes
,
Theme
,
get_theme_base_dir
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
request_cache.middleware
import
RequestCache
class
TestHelpers
(
TestCase
):
class
TestHelpers
(
TestCase
):
...
@@ -189,6 +190,8 @@ class TestHelpers(TestCase):
...
@@ -189,6 +190,8 @@ class TestHelpers(TestCase):
mock_microsite_backend
.
get_template
=
Mock
(
return_value
=
"/microsite/about.html"
)
mock_microsite_backend
.
get_template
=
Mock
(
return_value
=
"/microsite/about.html"
)
self
.
assertEqual
(
theming_helpers
.
get_template_path
(
"about.html"
),
"about.html"
)
self
.
assertEqual
(
theming_helpers
.
get_template_path
(
"about.html"
),
"about.html"
)
RequestCache
.
clear_request_cache
()
# if the current site does not have associated SiteTheme then get_template_path should return microsite override
# if the current site does not have associated SiteTheme then get_template_path should return microsite override
with
patch
(
with
patch
(
"openedx.core.djangoapps.theming.helpers.current_request_has_associated_site_theme"
,
"openedx.core.djangoapps.theming.helpers.current_request_has_associated_site_theme"
,
...
...
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