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
bd56ee21
Commit
bd56ee21
authored
Sep 16, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split get_item uses loc_mapper to decode old style Locations
parent
40d11c73
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
common/lib/xmodule/xmodule/modulestore/django.py
+6
-0
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+17
-4
No files found.
common/lib/xmodule/xmodule/modulestore/django.py
View file @
bd56ee21
...
@@ -75,6 +75,9 @@ def modulestore(name='default'):
...
@@ -75,6 +75,9 @@ def modulestore(name='default'):
if
name
not
in
_MODULESTORES
:
if
name
not
in
_MODULESTORES
:
_MODULESTORES
[
name
]
=
create_modulestore_instance
(
settings
.
MODULESTORE
[
name
][
'ENGINE'
],
_MODULESTORES
[
name
]
=
create_modulestore_instance
(
settings
.
MODULESTORE
[
name
][
'ENGINE'
],
settings
.
MODULESTORE
[
name
][
'OPTIONS'
])
settings
.
MODULESTORE
[
name
][
'OPTIONS'
])
# inject loc_mapper into newly created modulestore if it needs it
if
name
==
'split'
and
_loc_singleton
is
not
None
:
_MODULESTORES
[
'split'
]
.
loc_mapper
=
_loc_singleton
return
_MODULESTORES
[
name
]
return
_MODULESTORES
[
name
]
...
@@ -91,6 +94,9 @@ def loc_mapper():
...
@@ -91,6 +94,9 @@ def loc_mapper():
if
_loc_singleton
is
None
:
if
_loc_singleton
is
None
:
# instantiate
# instantiate
_loc_singleton
=
LocMapperStore
(
settings
.
modulestore_options
)
_loc_singleton
=
LocMapperStore
(
settings
.
modulestore_options
)
# inject into split mongo modulestore
if
'split'
in
_MODULESTORES
:
_MODULESTORES
[
'split'
]
.
loc_mapper
=
_loc_singleton
return
_loc_singleton
return
_loc_singleton
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
bd56ee21
...
@@ -5,20 +5,21 @@ import pymongo
...
@@ -5,20 +5,21 @@ import pymongo
import
re
import
re
from
importlib
import
import_module
from
importlib
import
import_module
from
path
import
path
from
path
import
path
import
collections
import
copy
from
pytz
import
UTC
from
xmodule.errortracker
import
null_error_tracker
from
xmodule.errortracker
import
null_error_tracker
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.modulestore.locator
import
BlockUsageLocator
,
DescriptionLocator
,
CourseLocator
,
VersionTree
,
LocalId
from
xmodule.modulestore.locator
import
BlockUsageLocator
,
DescriptionLocator
,
CourseLocator
,
VersionTree
,
LocalId
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
VersionConflictError
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
,
VersionConflictError
,
DuplicateItemError
from
xmodule.modulestore
import
inheritance
,
ModuleStoreBase
from
xmodule.modulestore
import
inheritance
,
ModuleStoreBase
,
Location
from
..exceptions
import
ItemNotFoundError
from
..exceptions
import
ItemNotFoundError
from
.definition_lazy_loader
import
DefinitionLazyLoader
from
.definition_lazy_loader
import
DefinitionLazyLoader
from
.caching_descriptor_system
import
CachingDescriptorSystem
from
.caching_descriptor_system
import
CachingDescriptorSystem
from
xblock.fields
import
Scope
from
xblock.fields
import
Scope
from
xblock.runtime
import
Mixologist
from
xblock.runtime
import
Mixologist
from
pytz
import
UTC
import
collections
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
#==============================================================================
#==============================================================================
...
@@ -49,14 +50,17 @@ class SplitMongoModuleStore(ModuleStoreBase):
...
@@ -49,14 +50,17 @@ class SplitMongoModuleStore(ModuleStoreBase):
A Mongodb backed ModuleStore supporting versions, inheritance,
A Mongodb backed ModuleStore supporting versions, inheritance,
and sharing.
and sharing.
"""
"""
# pylint: disable=C0103
def
__init__
(
self
,
host
,
db
,
collection
,
fs_root
,
render_template
,
def
__init__
(
self
,
host
,
db
,
collection
,
fs_root
,
render_template
,
port
=
27017
,
default_class
=
None
,
port
=
27017
,
default_class
=
None
,
error_tracker
=
null_error_tracker
,
error_tracker
=
null_error_tracker
,
user
=
None
,
password
=
None
,
user
=
None
,
password
=
None
,
mongo_options
=
None
,
mongo_options
=
None
,
loc_mapper
=
None
,
**
kwargs
):
**
kwargs
):
super
(
SplitMongoModuleStore
,
self
)
.
__init__
(
**
kwargs
)
super
(
SplitMongoModuleStore
,
self
)
.
__init__
(
**
kwargs
)
self
.
loc_mapper
=
loc_mapper
if
mongo_options
is
None
:
if
mongo_options
is
None
:
mongo_options
=
{}
mongo_options
=
{}
...
@@ -320,6 +324,15 @@ class SplitMongoModuleStore(ModuleStoreBase):
...
@@ -320,6 +324,15 @@ class SplitMongoModuleStore(ModuleStoreBase):
descendants.
descendants.
raises InsufficientSpecificationError or ItemNotFoundError
raises InsufficientSpecificationError or ItemNotFoundError
"""
"""
# intended for temporary support of some pointers being old-style
if
isinstance
(
location
,
Location
):
if
self
.
loc_mapper
is
None
:
raise
InsufficientSpecificationError
(
'No location mapper configured'
)
else
:
location
=
self
.
loc_mapper
.
translate_location
(
None
,
location
,
location
.
revision
is
None
,
add_entry_if_missing
=
False
)
assert
isinstance
(
location
,
BlockUsageLocator
)
assert
isinstance
(
location
,
BlockUsageLocator
)
if
not
location
.
is_initialized
():
if
not
location
.
is_initialized
():
raise
InsufficientSpecificationError
(
"Not yet initialized:
%
s"
%
location
)
raise
InsufficientSpecificationError
(
"Not yet initialized:
%
s"
%
location
)
...
...
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