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
2c90dc73
Commit
2c90dc73
authored
Sep 16, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't access kvs directly but use x_module and field_data mechanisms
parent
1c3c9217
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
12 deletions
+9
-12
common/lib/xmodule/xmodule/modulestore/inheritance.py
+1
-2
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+3
-6
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
+3
-2
common/lib/xmodule/xmodule/x_module.py
+2
-2
No files found.
common/lib/xmodule/xmodule/modulestore/inheritance.py
View file @
2c90dc73
...
@@ -56,8 +56,7 @@ def compute_inherited_metadata(descriptor):
...
@@ -56,8 +56,7 @@ def compute_inherited_metadata(descriptor):
parent_metadata
=
descriptor
.
xblock_kvs
.
inherited_settings
.
copy
()
parent_metadata
=
descriptor
.
xblock_kvs
.
inherited_settings
.
copy
()
# add any of descriptor's explicitly set fields to the inheriting list
# add any of descriptor's explicitly set fields to the inheriting list
for
field
in
InheritanceMixin
.
fields
.
values
():
for
field
in
InheritanceMixin
.
fields
.
values
():
# pylint: disable = W0212
if
field
.
is_set_on
(
descriptor
):
if
descriptor
.
_field_data
.
has
(
descriptor
,
field
.
name
):
# inherited_settings values are json repr
# inherited_settings values are json repr
parent_metadata
[
field
.
name
]
=
field
.
read_json
(
descriptor
)
parent_metadata
[
field
.
name
]
=
field
.
read_json
(
descriptor
)
...
...
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
2c90dc73
...
@@ -324,16 +324,14 @@ class MongoModuleStore(ModuleStoreBase):
...
@@ -324,16 +324,14 @@ class MongoModuleStore(ModuleStoreBase):
for
result
in
resultset
:
for
result
in
resultset
:
location
=
Location
(
result
[
'_id'
])
location
=
Location
(
result
[
'_id'
])
# We need to collate between draft and non-draft
# We need to collate between draft and non-draft
# i.e. draft verticals
can have children which are not in non-draft versions
# i.e. draft verticals
will have draft children but will have non-draft parents currently
location
=
location
.
replace
(
revision
=
None
)
location
=
location
.
replace
(
revision
=
None
)
location_url
=
location
.
url
()
location_url
=
location
.
url
()
if
location_url
in
results_by_url
:
if
location_url
in
results_by_url
:
existing_children
=
results_by_url
[
location_url
]
.
get
(
'definition'
,
{})
.
get
(
'children'
,
[])
existing_children
=
results_by_url
[
location_url
]
.
get
(
'definition'
,
{})
.
get
(
'children'
,
[])
additional_children
=
result
.
get
(
'definition'
,
{})
.
get
(
'children'
,
[])
additional_children
=
result
.
get
(
'definition'
,
{})
.
get
(
'children'
,
[])
total_children
=
existing_children
+
additional_children
total_children
=
existing_children
+
additional_children
if
'definition'
not
in
results_by_url
[
location_url
]:
results_by_url
[
location_url
]
.
setdefault
(
'definition'
,
{})[
'children'
]
=
total_children
results_by_url
[
location_url
][
'definition'
]
=
{}
results_by_url
[
location_url
][
'definition'
][
'children'
]
=
total_children
results_by_url
[
location
.
url
()]
=
result
results_by_url
[
location
.
url
()]
=
result
if
location
.
category
==
'course'
:
if
location
.
category
==
'course'
:
root
=
location
.
url
()
root
=
location
.
url
()
...
@@ -643,12 +641,11 @@ class MongoModuleStore(ModuleStoreBase):
...
@@ -643,12 +641,11 @@ class MongoModuleStore(ModuleStoreBase):
"""
"""
# Save any changes to the xmodule to the MongoKeyValueStore
# Save any changes to the xmodule to the MongoKeyValueStore
xmodule
.
save
()
xmodule
.
save
()
# split mongo's persist_dag is more general and useful.
self
.
collection
.
save
({
self
.
collection
.
save
({
'_id'
:
xmodule
.
location
.
dict
(),
'_id'
:
xmodule
.
location
.
dict
(),
'metadata'
:
own_metadata
(
xmodule
),
'metadata'
:
own_metadata
(
xmodule
),
'definition'
:
{
'definition'
:
{
'data'
:
xmodule
.
xblock_kvs
.
_data
,
'data'
:
xmodule
.
get_explicitly_set_fields_by_scope
(
Scope
.
content
)
,
'children'
:
xmodule
.
children
if
xmodule
.
has_children
else
[]
'children'
:
xmodule
.
children
if
xmodule
.
has_children
else
[]
}
}
})
})
...
...
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
View file @
2c90dc73
...
@@ -15,6 +15,7 @@ from xmodule.modulestore.inheritance import own_metadata
...
@@ -15,6 +15,7 @@ from xmodule.modulestore.inheritance import own_metadata
from
xmodule.modulestore.mongo.base
import
location_to_query
,
namedtuple_to_son
,
get_course_id_no_run
,
MongoModuleStore
from
xmodule.modulestore.mongo.base
import
location_to_query
,
namedtuple_to_son
,
get_course_id_no_run
,
MongoModuleStore
import
pymongo
import
pymongo
from
pytz
import
UTC
from
pytz
import
UTC
from
xblock.fields
import
Scope
DRAFT
=
'draft'
DRAFT
=
'draft'
# Things w/ these categories should never be marked as version='draft'
# Things w/ these categories should never be marked as version='draft'
...
@@ -237,8 +238,8 @@ class DraftModuleStore(MongoModuleStore):
...
@@ -237,8 +238,8 @@ class DraftModuleStore(MongoModuleStore):
draft
.
published_date
=
datetime
.
now
(
UTC
)
draft
.
published_date
=
datetime
.
now
(
UTC
)
draft
.
published_by
=
published_by_id
draft
.
published_by
=
published_by_id
super
(
DraftModuleStore
,
self
)
.
update_item
(
location
,
draft
.
_field_data
.
_kvs
.
_data
)
super
(
DraftModuleStore
,
self
)
.
update_item
(
location
,
draft
.
get_explicitly_set_fields_by_scope
(
Scope
.
content
)
)
super
(
DraftModuleStore
,
self
)
.
update_children
(
location
,
draft
.
_field_data
.
_kvs
.
_
children
)
super
(
DraftModuleStore
,
self
)
.
update_children
(
location
,
draft
.
children
)
super
(
DraftModuleStore
,
self
)
.
update_metadata
(
location
,
own_metadata
(
draft
))
super
(
DraftModuleStore
,
self
)
.
update_metadata
(
location
,
own_metadata
(
draft
))
self
.
delete_item
(
location
)
self
.
delete_item
(
location
)
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
2c90dc73
...
@@ -670,8 +670,8 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
...
@@ -670,8 +670,8 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
"""
"""
result
=
{}
result
=
{}
for
field
in
self
.
fields
.
values
():
for
field
in
self
.
fields
.
values
():
if
(
field
.
scope
==
scope
and
self
.
_field_data
.
has
(
self
,
field
.
name
)):
if
(
field
.
scope
==
scope
and
field
.
is_set_on
(
self
)):
result
[
field
.
name
]
=
self
.
_field_data
.
get
(
self
,
field
.
name
)
result
[
field
.
name
]
=
field
.
read_json
(
self
)
return
result
return
result
@property
@property
...
...
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