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
30b5822b
Commit
30b5822b
authored
Feb 23, 2017
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storage-backed versioned Block Structures: Config
parent
78644495
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
7 deletions
+32
-7
openedx/core/djangoapps/content/block_structure/config.py
+28
-0
openedx/core/djangoapps/content/block_structure/signals.py
+2
-5
openedx/core/djangoapps/content/block_structure/tests/test_signals.py
+2
-2
No files found.
openedx/core/djangoapps/content/block_structure/config.py
0 → 100644
View file @
30b5822b
"""
This module contains various configuration settings via
waffle switches for the Block Structure framework.
"""
from
waffle
import
switch_is_active
INVALIDATE_CACHE_ON_PUBLISH
=
u'invalidate_cache_on_publish'
STORAGE_BACKING_FOR_CACHE
=
u'storage_backing_for_cache'
RAISE_ERROR_WHEN_NOT_FOUND
=
u'raise_error_when_not_found'
def
is_enabled
(
setting_name
):
"""
Returns whether the given setting is enabled.
"""
return
switch_is_active
(
waffle_switch_name
(
setting_name
)
)
def
waffle_switch_name
(
setting_name
):
"""
Returns the name of the waffle switch for the
given name of the setting.
"""
return
u'block_structure.{}'
.
format
(
setting_name
)
openedx/core/djangoapps/content/block_structure/signals.py
View file @
30b5822b
...
@@ -5,22 +5,19 @@ from django.conf import settings
...
@@ -5,22 +5,19 @@ from django.conf import settings
from
django.dispatch.dispatcher
import
receiver
from
django.dispatch.dispatcher
import
receiver
from
xmodule.modulestore.django
import
SignalHandler
from
xmodule.modulestore.django
import
SignalHandler
from
waffle
import
switch_is_active
from
.
import
config
from
.api
import
clear_course_from_cache
from
.api
import
clear_course_from_cache
from
.tasks
import
update_course_in_cache
from
.tasks
import
update_course_in_cache
INVALIDATE_CACHE_ON_PUBLISH_SWITCH
=
'block_structure_invalidate_cache_on_publish'
@receiver
(
SignalHandler
.
course_published
)
@receiver
(
SignalHandler
.
course_published
)
def
_listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
def
_listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
"""
"""
Catches the signal that a course has been published in the module
Catches the signal that a course has been published in the module
store and creates/updates the corresponding cache entry.
store and creates/updates the corresponding cache entry.
"""
"""
if
switch_is_active
(
INVALIDATE_CACHE_ON_PUBLISH_SWITC
H
):
if
config
.
is_enabled
(
config
.
INVALIDATE_CACHE_ON_PUBLIS
H
):
clear_course_from_cache
(
course_key
)
clear_course_from_cache
(
course_key
)
update_course_in_cache
.
apply_async
(
update_course_in_cache
.
apply_async
(
...
...
openedx/core/djangoapps/content/block_structure/tests/test_signals.py
View file @
30b5822b
...
@@ -10,7 +10,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
...
@@ -10,7 +10,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
..api
import
get_block_structure_manager
from
..api
import
get_block_structure_manager
from
..
signals
import
INVALIDATE_CACHE_ON_PUBLISH_SWITCH
from
..
config
import
INVALIDATE_CACHE_ON_PUBLISH
,
waffle_switch_name
from
.helpers
import
is_course_in_block_structure_cache
from
.helpers
import
is_course_in_block_structure_cache
...
@@ -51,7 +51,7 @@ class CourseBlocksSignalTest(ModuleStoreTestCase):
...
@@ -51,7 +51,7 @@ class CourseBlocksSignalTest(ModuleStoreTestCase):
def
test_cache_invalidation
(
self
,
invalidate_cache_enabled
,
mock_bs_manager_clear
):
def
test_cache_invalidation
(
self
,
invalidate_cache_enabled
,
mock_bs_manager_clear
):
test_display_name
=
"Jedi 101"
test_display_name
=
"Jedi 101"
with
override_switch
(
INVALIDATE_CACHE_ON_PUBLISH_SWITCH
,
active
=
invalidate_cache_enabled
):
with
override_switch
(
waffle_switch_name
(
INVALIDATE_CACHE_ON_PUBLISH
)
,
active
=
invalidate_cache_enabled
):
self
.
course
.
display_name
=
test_display_name
self
.
course
.
display_name
=
test_display_name
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
...
...
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