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
9338b6a4
Commit
9338b6a4
authored
Apr 15, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push `delete` down into FieldDataCache from DjangoKeyValueStore
parent
ebb3c906
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
lms/djangoapps/courseware/model_data.py
+23
-11
No files found.
lms/djangoapps/courseware/model_data.py
View file @
9338b6a4
...
...
@@ -159,17 +159,7 @@ class DjangoKeyValueStore(KeyValueStore):
if
key
.
scope
not
in
self
.
_allowed_scopes
:
raise
InvalidScopeError
(
key
)
field_object
=
self
.
_field_data_cache
.
find
(
key
)
if
field_object
is
None
:
raise
KeyError
(
key
.
field_name
)
if
key
.
scope
==
Scope
.
user_state
:
state
=
json
.
loads
(
field_object
.
state
)
del
state
[
key
.
field_name
]
field_object
.
state
=
json
.
dumps
(
state
)
field_object
.
save
()
else
:
field_object
.
delete
()
self
.
_field_data_cache
.
delete
(
key
)
def
has
(
self
,
key
):
if
key
.
scope
not
in
self
.
_allowed_scopes
:
...
...
@@ -651,6 +641,28 @@ class FieldDataCache(object):
log
.
exception
(
'Error saving fields
%
r'
,
field_objects
[
field_object
])
raise
KeyValueMultiSaveError
(
saved_fields
)
@contract
(
key
=
DjangoKeyValueStore
.
Key
)
def
delete
(
self
,
key
):
"""
Delete the value specified by `key`.
Arguments:
key (`DjangoKeyValueStore.Key`): The field value to delete
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
:
state
=
json
.
loads
(
field_object
.
state
)
del
state
[
key
.
field_name
]
field_object
.
state
=
json
.
dumps
(
state
)
field_object
.
save
()
else
:
field_object
.
delete
()
def
find
(
self
,
key
):
'''
Look for a model data object using an DjangoKeyValueStore.Key object
...
...
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