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
951c19d7
Commit
951c19d7
authored
Apr 15, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push `get` down into FieldDataCache, from DjangoKeyValueStore
parent
5df3c226
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
lms/djangoapps/courseware/model_data.py
+20
-8
No files found.
lms/djangoapps/courseware/model_data.py
View file @
951c19d7
...
@@ -132,14 +132,7 @@ class DjangoKeyValueStore(KeyValueStore):
...
@@ -132,14 +132,7 @@ class DjangoKeyValueStore(KeyValueStore):
if
key
.
scope
not
in
self
.
_allowed_scopes
:
if
key
.
scope
not
in
self
.
_allowed_scopes
:
raise
InvalidScopeError
(
key
)
raise
InvalidScopeError
(
key
)
field_object
=
self
.
_field_data_cache
.
find
(
key
)
return
self
.
_field_data_cache
.
get
(
key
)
if
field_object
is
None
:
raise
KeyError
(
key
.
field_name
)
if
key
.
scope
==
Scope
.
user_state
:
return
json
.
loads
(
field_object
.
state
)[
key
.
field_name
]
else
:
return
json
.
loads
(
field_object
.
value
)
def
set
(
self
,
key
,
value
):
def
set
(
self
,
key
,
value
):
"""
"""
...
@@ -622,6 +615,25 @@ class FieldDataCache(object):
...
@@ -622,6 +615,25 @@ class FieldDataCache(object):
scope_map
[
field
.
scope
]
.
add
(
field
)
scope_map
[
field
.
scope
]
.
add
(
field
)
return
scope_map
return
scope_map
@contract
(
key
=
DjangoKeyValueStore
.
Key
)
def
get
(
self
,
key
):
'''
Load the field value specified by `key`.
Arguments:
key (`DjangoKeyValueStore.Key`): The field value to load
Returns: The found value
Raises: KeyError if key isn't found in the cache
'''
field_object
=
self
.
find
(
key
)
if
field_object
is
None
:
raise
KeyError
(
key
.
field_name
)
if
key
.
scope
==
Scope
.
user_state
:
return
json
.
loads
(
field_object
.
state
)[
key
.
field_name
]
else
:
return
json
.
loads
(
field_object
.
value
)
def
find
(
self
,
key
):
def
find
(
self
,
key
):
'''
'''
...
...
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