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
4b068683
Commit
4b068683
authored
Sep 16, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make modulestores properly propogate **kwargs
parent
a14fbe4c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
10 deletions
+18
-10
common/lib/xmodule/xmodule/modulestore/__init__.py
+1
-1
common/lib/xmodule/xmodule/modulestore/django.py
+8
-2
common/lib/xmodule/xmodule/modulestore/draft_and_published.py
+1
-1
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+4
-2
common/lib/xmodule/xmodule/modulestore/xml.py
+4
-4
No files found.
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
4b068683
...
...
@@ -634,7 +634,7 @@ class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead):
'''
Set up the error-tracking logic.
'''
super
(
ModuleStoreReadBase
,
self
)
.
__init__
()
super
(
ModuleStoreReadBase
,
self
)
.
__init__
(
**
kwargs
)
self
.
_course_errors
=
defaultdict
(
make_error_tracker
)
# location -> ErrorLog
# TODO move the inheritance_cache_subsystem to classes which use it
self
.
metadata_inheritance_cache_subsystem
=
metadata_inheritance_cache_subsystem
...
...
common/lib/xmodule/xmodule/modulestore/django.py
View file @
4b068683
...
...
@@ -18,6 +18,8 @@ import threading
from
xmodule.util.django
import
get_current_request_hostname
import
xmodule.modulestore
# pylint: disable=unused-import
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.modulestore.draft_and_published
import
BranchSettingMixin
from
xmodule.contentstore.django
import
contentstore
import
xblock.reference.plugins
...
...
@@ -66,6 +68,12 @@ def create_modulestore_instance(engine, content_store, doc_store_config, options
except
InvalidCacheBackendError
:
metadata_inheritance_cache
=
get_cache
(
'default'
)
if
issubclass
(
class_
,
MixedModuleStore
):
_options
[
'create_modulestore_instance'
]
=
create_modulestore_instance
if
issubclass
(
class_
,
BranchSettingMixin
):
_options
[
'branch_setting_func'
]
=
_get_modulestore_branch_setting
return
class_
(
contentstore
=
content_store
,
metadata_inheritance_cache_subsystem
=
metadata_inheritance_cache
,
...
...
@@ -75,8 +83,6 @@ def create_modulestore_instance(engine, content_store, doc_store_config, options
doc_store_config
=
doc_store_config
,
i18n_service
=
i18n_service
or
ModuleI18nService
(),
fs_service
=
fs_service
or
xblock
.
reference
.
plugins
.
FSService
(),
branch_setting_func
=
_get_modulestore_branch_setting
,
create_modulestore_instance
=
create_modulestore_instance
,
**
_options
)
...
...
common/lib/xmodule/xmodule/modulestore/draft_and_published.py
View file @
4b068683
...
...
@@ -25,11 +25,11 @@ class BranchSettingMixin(object):
:param branch_setting_func: a function that returns the default branch setting for this object.
If not specified, ModuleStoreEnum.Branch.published_only is used as the default setting.
"""
super
(
BranchSettingMixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
default_branch_setting_func
=
kwargs
.
pop
(
'branch_setting_func'
,
lambda
:
ModuleStoreEnum
.
Branch
.
published_only
)
super
(
BranchSettingMixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
# cache the branch setting on a local thread to support a multi-threaded environment
self
.
thread_cache
=
threading
.
local
()
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
4b068683
...
...
@@ -27,7 +27,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
from
xmodule.exceptions
import
InvalidVersionError
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
,
ModuleStoreDraftAndPublished
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
DuplicateCourseError
,
ReferentialIntegrityError
,
NoPathToItem
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.modulestore.search
import
path_to_location
...
...
@@ -1789,9 +1789,11 @@ def create_modulestore_instance(engine, contentstore, doc_store_config, options,
"""
class_
=
load_function
(
engine
)
if
issubclass
(
class_
,
ModuleStoreDraftAndPublished
):
options
[
'branch_setting_func'
]
=
lambda
:
ModuleStoreEnum
.
Branch
.
draft_preferred
return
class_
(
doc_store_config
=
doc_store_config
,
contentstore
=
contentstore
,
branch_setting_func
=
lambda
:
ModuleStoreEnum
.
Branch
.
draft_preferred
,
**
options
)
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
4b068683
...
...
@@ -370,7 +370,7 @@ class XMLModuleStore(ModuleStoreReadBase):
"""
def
__init__
(
self
,
data_dir
,
default_class
=
None
,
course_dirs
=
None
,
course_ids
=
None
,
load_error_modules
=
True
,
i18n_service
=
None
,
py
fs_service
=
None
,
**
kwargs
load_error_modules
=
True
,
i18n_service
=
None
,
fs_service
=
None
,
**
kwargs
):
"""
Initialize an XMLModuleStore from data_dir
...
...
@@ -409,7 +409,7 @@ class XMLModuleStore(ModuleStoreReadBase):
self
.
field_data
=
inheriting_field_data
(
kvs
=
DictKeyValueStore
())
self
.
i18n_service
=
i18n_service
self
.
pyfs_service
=
py
fs_service
self
.
fs_service
=
fs_service
# If we are specifically asked for missing courses, that should
# be an error. If we are asked for "all" courses, find the ones
...
...
@@ -555,8 +555,8 @@ class XMLModuleStore(ModuleStoreReadBase):
if
self
.
i18n_service
:
services
[
'i18n'
]
=
self
.
i18n_service
if
self
.
py
fs_service
:
services
[
'fs'
]
=
self
.
py
fs_service
if
self
.
fs_service
:
services
[
'fs'
]
=
self
.
fs_service
system
=
ImportSystem
(
xmlstore
=
self
,
...
...
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