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
3c7aa18d
Commit
3c7aa18d
authored
Jul 09, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use raw asserts in split (to handle different types of UsageKeys sanely)
parent
1bc0b323
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+16
-4
No files found.
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
3c7aa18d
...
@@ -374,7 +374,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -374,7 +374,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
'''
'''
Gets the course descriptor for the course identified by the locator
Gets the course descriptor for the course identified by the locator
'''
'''
assert
(
isinstance
(
course_id
,
CourseLocator
))
if
not
isinstance
(
course_id
,
CourseLocator
):
# The supplied CourseKey is of the wrong type, so it can't possibly be stored in this modulestore.
raise
ItemNotFoundError
(
course_id
)
course_entry
=
self
.
_lookup_course
(
course_id
)
course_entry
=
self
.
_lookup_course
(
course_id
)
root
=
course_entry
[
'structure'
][
'root'
]
root
=
course_entry
[
'structure'
][
'root'
]
result
=
self
.
_load_items
(
course_entry
,
[
root
],
0
,
lazy
=
True
)
result
=
self
.
_load_items
(
course_entry
,
[
root
],
0
,
lazy
=
True
)
...
@@ -389,7 +392,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -389,7 +392,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
Note: we return the course_id instead of a boolean here since the found course may have
Note: we return the course_id instead of a boolean here since the found course may have
a different id than the given course_id when ignore_case is True.
a different id than the given course_id when ignore_case is True.
'''
'''
assert
(
isinstance
(
course_id
,
CourseLocator
))
if
not
isinstance
(
course_id
,
CourseLocator
):
# The supplied CourseKey is of the wrong type, so it can't possibly be stored in this modulestore.
return
False
course_index
=
self
.
db_connection
.
get_course_index
(
course_id
,
ignore_case
)
course_index
=
self
.
db_connection
.
get_course_index
(
course_id
,
ignore_case
)
return
CourseLocator
(
course_index
[
'org'
],
course_index
[
'course'
],
course_index
[
'run'
],
course_id
.
branch
)
if
course_index
else
None
return
CourseLocator
(
course_index
[
'org'
],
course_index
[
'course'
],
course_index
[
'run'
],
course_id
.
branch
)
if
course_index
else
None
...
@@ -432,7 +438,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -432,7 +438,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
descendants.
descendants.
raises InsufficientSpecificationError or ItemNotFoundError
raises InsufficientSpecificationError or ItemNotFoundError
"""
"""
assert
isinstance
(
usage_key
,
BlockUsageLocator
)
if
not
isinstance
(
usage_key
,
BlockUsageLocator
):
# The supplied UsageKey is of the wrong type, so it can't possibly be stored in this modulestore.
raise
ItemNotFoundError
(
usage_key
)
course
=
self
.
_lookup_course
(
usage_key
)
course
=
self
.
_lookup_course
(
usage_key
)
items
=
self
.
_load_items
(
course
,
[
usage_key
.
block_id
],
depth
,
lazy
=
True
)
items
=
self
.
_load_items
(
course
,
[
usage_key
.
block_id
],
depth
,
lazy
=
True
)
if
len
(
items
)
==
0
:
if
len
(
items
)
==
0
:
...
@@ -1375,7 +1384,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -1375,7 +1384,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
change to this item, it raises a VersionConflictError unless force is True. In the force case, it forks
change to this item, it raises a VersionConflictError unless force is True. In the force case, it forks
the course but leaves the head pointer where it is (this change will not be in the course head).
the course but leaves the head pointer where it is (this change will not be in the course head).
"""
"""
assert
isinstance
(
usage_locator
,
BlockUsageLocator
)
if
not
isinstance
(
usage_locator
,
BlockUsageLocator
):
# The supplied UsageKey is of the wrong type, so it can't possibly be stored in this modulestore.
raise
ItemNotFoundError
(
usage_locator
)
original_structure
=
self
.
_lookup_course
(
usage_locator
.
course_key
)[
'structure'
]
original_structure
=
self
.
_lookup_course
(
usage_locator
.
course_key
)[
'structure'
]
if
original_structure
[
'root'
]
==
usage_locator
.
block_id
:
if
original_structure
[
'root'
]
==
usage_locator
.
block_id
:
raise
ValueError
(
"Cannot delete the root of a course"
)
raise
ValueError
(
"Cannot delete the root of a course"
)
...
...
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