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
bd1e9aa1
Commit
bd1e9aa1
authored
May 18, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Record valid scopes when raising InvalidScopeError
parent
3e8631c2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
+21
-10
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+12
-3
common/lib/xmodule/xmodule/modulestore/split_mongo/split_mongo_kvs.py
+7
-5
lms/djangoapps/courseware/model_data.py
+1
-1
requirements/edx/github.txt
+1
-1
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
bd1e9aa1
...
...
@@ -119,7 +119,10 @@ class MongoKeyValueStore(InheritanceKeyValueStore):
elif
key
.
scope
==
Scope
.
content
:
return
self
.
_data
[
key
.
field_name
]
else
:
raise
InvalidScopeError
(
key
)
raise
InvalidScopeError
(
key
,
(
Scope
.
children
,
Scope
.
parent
,
Scope
.
settings
,
Scope
.
content
),
)
def
set
(
self
,
key
,
value
):
if
key
.
scope
==
Scope
.
children
:
...
...
@@ -129,7 +132,10 @@ class MongoKeyValueStore(InheritanceKeyValueStore):
elif
key
.
scope
==
Scope
.
content
:
self
.
_data
[
key
.
field_name
]
=
value
else
:
raise
InvalidScopeError
(
key
)
raise
InvalidScopeError
(
key
,
(
Scope
.
children
,
Scope
.
settings
,
Scope
.
content
),
)
def
delete
(
self
,
key
):
if
key
.
scope
==
Scope
.
children
:
...
...
@@ -141,7 +147,10 @@ class MongoKeyValueStore(InheritanceKeyValueStore):
if
key
.
field_name
in
self
.
_data
:
del
self
.
_data
[
key
.
field_name
]
else
:
raise
InvalidScopeError
(
key
)
raise
InvalidScopeError
(
key
,
(
Scope
.
children
,
Scope
.
settings
,
Scope
.
content
),
)
def
has
(
self
,
key
):
if
key
.
scope
in
(
Scope
.
children
,
Scope
.
parent
):
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split_mongo_kvs.py
View file @
bd1e9aa1
...
...
@@ -18,6 +18,8 @@ class SplitMongoKVS(InheritanceKeyValueStore):
known to the MongoModuleStore (data, children, and metadata)
"""
VALID_SCOPES
=
(
Scope
.
parent
,
Scope
.
children
,
Scope
.
settings
,
Scope
.
content
)
@contract
(
parent
=
"BlockUsageLocator | None"
)
def
__init__
(
self
,
definition
,
initial_values
,
default_values
,
parent
,
field_decorator
=
None
):
"""
...
...
@@ -59,7 +61,7 @@ class SplitMongoKVS(InheritanceKeyValueStore):
else
:
raise
KeyError
()
else
:
raise
InvalidScopeError
(
key
)
raise
InvalidScopeError
(
key
,
self
.
VALID_SCOPES
)
if
key
.
field_name
in
self
.
_fields
:
field_value
=
self
.
_fields
[
key
.
field_name
]
...
...
@@ -71,8 +73,8 @@ class SplitMongoKVS(InheritanceKeyValueStore):
def
set
(
self
,
key
,
value
):
# handle any special cases
if
key
.
scope
not
in
[
Scope
.
children
,
Scope
.
settings
,
Scope
.
content
]
:
raise
InvalidScopeError
(
key
)
if
key
.
scope
not
in
self
.
VALID_SCOPES
:
raise
InvalidScopeError
(
key
,
self
.
VALID_SCOPES
)
if
key
.
scope
==
Scope
.
content
:
self
.
_load_definition
()
...
...
@@ -90,8 +92,8 @@ class SplitMongoKVS(InheritanceKeyValueStore):
def
delete
(
self
,
key
):
# handle any special cases
if
key
.
scope
not
in
[
Scope
.
children
,
Scope
.
settings
,
Scope
.
content
]
:
raise
InvalidScopeError
(
key
)
if
key
.
scope
not
in
self
.
VALID_SCOPES
:
raise
InvalidScopeError
(
key
,
self
.
VALID_SCOPES
)
if
key
.
scope
==
Scope
.
content
:
self
.
_load_definition
()
...
...
lms/djangoapps/courseware/model_data.py
View file @
bd1e9aa1
...
...
@@ -129,7 +129,7 @@ class DjangoKeyValueStore(KeyValueStore):
def
_raise_unless_scope_is_allowed
(
self
,
key
):
"""Raise an InvalidScopeError if key.scope is not in self._allowed_scopes."""
if
key
.
scope
not
in
self
.
_allowed_scopes
:
raise
InvalidScopeError
(
key
)
raise
InvalidScopeError
(
key
,
self
.
_allowed_scopes
)
new_contract
(
"DjangoKeyValueStore"
,
DjangoKeyValueStore
)
...
...
requirements/edx/github.txt
View file @
bd1e9aa1
...
...
@@ -29,7 +29,7 @@ git+https://github.com/pmitros/pyfs.git@96e1922348bfe6d99201b9512a9ed946c87b7e0b
git+https://github.com/hmarr/django-debug-toolbar-mongo.git@b0686a76f1ce3532088c4aee6e76b9abe61cc808
# Our libraries:
-e git+https://github.com/
edx/XBlock.git@1934a2978cdd3e2414486c74b76e3040ff1fb138
#egg=XBlock
-e git+https://github.com/
cpennington/XBlock.git@e9c4d441d1eaf7c9f176b873fe23e24c1152dba6
#egg=XBlock
-e git+https://github.com/edx/codejail.git@6b17c33a89bef0ac510926b1d7fea2748b73aadd#egg=codejail
-e git+https://github.com/edx/js-test-tool.git@v0.1.6#egg=js_test_tool
-e git+https://github.com/edx/event-tracking.git@0.2.0#egg=event-tracking
...
...
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