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
6da7bff1
Commit
6da7bff1
authored
Sep 25, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow test_mixed_modulestore to be run without django setup
parent
92eadf1a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
24 deletions
+33
-24
common/lib/xmodule/xmodule/modulestore/__init__.py
+2
-17
common/lib/xmodule/xmodule/modulestore/draft_and_published.py
+19
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py
+12
-5
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+0
-0
No files found.
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
6da7bff1
...
...
@@ -315,7 +315,8 @@ class BulkOperationsMixin(object):
Sends out the signal that items have been published from within this course.
"""
if
self
.
signal_handler
and
bulk_ops_record
.
has_publish_item
:
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_id
)
# We remove the branch, because publishing always means copying from draft to published
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_id
.
for_branch
(
None
))
bulk_ops_record
.
has_publish_item
=
False
def
send_bulk_library_updated_signal
(
self
,
bulk_ops_record
,
library_id
):
...
...
@@ -1345,22 +1346,6 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite):
parent
.
children
.
append
(
item
.
location
)
self
.
update_item
(
parent
,
user_id
)
def
_flag_publish_event
(
self
,
course_key
):
"""
Wrapper around calls to fire the course_published signal
Unless we're nested in an active bulk operation, this simply fires the signal
otherwise a publish will be signalled at the end of the bulk operation
Arguments:
course_key - course_key to which the signal applies
"""
if
self
.
signal_handler
:
bulk_record
=
self
.
_get_bulk_ops_record
(
course_key
)
if
isinstance
(
self
,
BulkOperationsMixin
)
else
None
if
bulk_record
and
bulk_record
.
active
:
bulk_record
.
has_publish_item
=
True
else
:
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_key
)
def
_flag_library_updated_event
(
self
,
library_key
):
"""
Wrapper around calls to fire the library_updated signal
...
...
common/lib/xmodule/xmodule/modulestore/draft_and_published.py
View file @
6da7bff1
...
...
@@ -5,7 +5,7 @@ This module provides an abstraction for Module Stores that support Draft and Pub
import
threading
from
abc
import
ABCMeta
,
abstractmethod
from
contextlib
import
contextmanager
from
.
import
ModuleStoreEnum
from
.
import
ModuleStoreEnum
,
BulkOperationsMixin
# Things w/ these categories should never be marked as version=DRAFT
DIRECT_ONLY_CATEGORIES
=
[
'course'
,
'chapter'
,
'sequential'
,
'about'
,
'static_tab'
,
'course_info'
]
...
...
@@ -62,7 +62,7 @@ class BranchSettingMixin(object):
return
self
.
default_branch_setting_func
()
class
ModuleStoreDraftAndPublished
(
BranchSettingMixin
):
class
ModuleStoreDraftAndPublished
(
BranchSettingMixin
,
BulkOperationsMixin
):
"""
A mixin for a read-write database backend that supports two branches, Draft and Published, with
options to prefer Draft and fallback to Published.
...
...
@@ -112,6 +112,23 @@ class ModuleStoreDraftAndPublished(BranchSettingMixin):
"""
raise
NotImplementedError
def
_flag_publish_event
(
self
,
course_key
):
"""
Wrapper around calls to fire the course_published signal
Unless we're nested in an active bulk operation, this simply fires the signal
otherwise a publish will be signalled at the end of the bulk operation
Arguments:
course_key - course_key to which the signal applies
"""
if
self
.
signal_handler
:
bulk_record
=
self
.
_get_bulk_ops_record
(
course_key
)
if
isinstance
(
self
,
BulkOperationsMixin
)
else
None
if
bulk_record
and
bulk_record
.
active
:
bulk_record
.
has_publish_item
=
True
else
:
# We remove the branch, because publishing always means copying from draft to published
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_key
.
for_branch
(
None
))
class
UnsupportedRevisionError
(
ValueError
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py
View file @
6da7bff1
...
...
@@ -13,7 +13,13 @@ from time import time
# Import this just to export it
from
pymongo.errors
import
DuplicateKeyError
# pylint: disable=unused-import
from
django.core.cache
import
get_cache
,
InvalidCacheBackendError
try
:
from
django.core.cache
import
get_cache
,
InvalidCacheBackendError
DJANGO_AVAILABLE
=
True
except
ImportError
:
DJANGO_AVAILABLE
=
False
import
dogstats_wrapper
as
dog_stats_api
from
contracts
import
check
,
new_contract
...
...
@@ -216,15 +222,16 @@ class CourseStructureCache(object):
for set and get.
"""
def
__init__
(
self
):
self
.
no_cache_found
=
False
self
.
cache
=
None
if
DJANGO_AVAILABLE
:
try
:
self
.
cache
=
get_cache
(
'course_structure_cache'
)
except
InvalidCacheBackendError
:
self
.
no_cache_found
=
True
pass
def
get
(
self
,
key
,
course_context
=
None
):
"""Pull the compressed, pickled struct data from cache and deserialize."""
if
self
.
no_cache_found
:
if
self
.
cache
is
None
:
return
None
with
TIMER
.
timer
(
"CourseStructureCache.get"
,
course_context
)
as
tagger
:
...
...
@@ -245,7 +252,7 @@ class CourseStructureCache(object):
def
set
(
self
,
key
,
structure
,
course_context
=
None
):
"""Given a structure, will pickle, compress, and write to cache."""
if
self
.
no_cache_found
:
if
self
.
cache
is
None
:
return
None
with
TIMER
.
timer
(
"CourseStructureCache.set"
,
course_context
)
as
tagger
:
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
6da7bff1
This diff is collapsed.
Click to expand it.
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