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
acc02b0e
Commit
acc02b0e
authored
Jun 05, 2014
by
Don Mitchell
Committed by
Sarina Canelake
Jun 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to excess asset query
parent
ade82c2d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
21 deletions
+13
-21
cms/djangoapps/contentstore/features/transcripts.py
+1
-1
cms/djangoapps/contentstore/tests/test_transcripts_utils.py
+2
-2
common/lib/xmodule/xmodule/contentstore/content.py
+1
-1
common/lib/xmodule/xmodule/contentstore/mongo.py
+8
-15
lms/djangoapps/courseware/tests/test_video_handlers.py
+1
-2
No files found.
cms/djangoapps/contentstore/features/transcripts.py
View file @
acc02b0e
...
...
@@ -171,7 +171,7 @@ def remove_transcripts_from_store(_step, subs_id):
)
try
:
content
=
contentstore
()
.
find
(
content_location
)
contentstore
()
.
delete
(
content
.
get_id
()
)
contentstore
()
.
delete
(
content
.
location
)
print
(
'Transcript file was removed from store.'
)
except
NotFoundError
:
print
(
'Transcript file was NOT found and not removed.'
)
...
...
cms/djangoapps/contentstore/tests/test_transcripts_utils.py
View file @
acc02b0e
...
...
@@ -88,7 +88,7 @@ class TestSaveSubsToStore(ModuleStoreTestCase):
"""Remove, if subtitles content exists."""
try
:
content
=
contentstore
()
.
find
(
self
.
content_location
)
contentstore
()
.
delete
(
content
.
get_id
()
)
contentstore
()
.
delete
(
content
.
location
)
except
NotFoundError
:
pass
...
...
@@ -171,7 +171,7 @@ class TestDownloadYoutubeSubs(ModuleStoreTestCase):
content_location
=
StaticContent
.
compute_location
(
self
.
course
.
id
,
filename
)
try
:
content
=
contentstore
()
.
find
(
content_location
)
contentstore
()
.
delete
(
content
.
get_id
()
)
contentstore
()
.
delete
(
content
.
location
)
except
NotFoundError
:
pass
...
...
common/lib/xmodule/xmodule/contentstore/content.py
View file @
acc02b0e
...
...
@@ -59,7 +59,7 @@ class StaticContent(object):
)
def
get_id
(
self
):
return
self
.
location
.
to_deprecated_son
(
tag
=
XASSET_LOCATION_TAG
)
return
self
.
location
def
get_url_path
(
self
):
return
self
.
location
.
to_deprecated_string
()
...
...
common/lib/xmodule/xmodule/contentstore/mongo.py
View file @
acc02b0e
...
...
@@ -12,7 +12,7 @@ from xmodule.exceptions import NotFoundError
from
fs.osfs
import
OSFS
import
os
import
json
import
bson.son
from
bson.son
import
SON
from
xmodule.modulestore.locations
import
AssetLocation
...
...
@@ -29,7 +29,7 @@ class MongoContentStore(ContentStore):
pymongo
.
MongoClient
(
host
=
host
,
port
=
port
,
document_class
=
bson
.
son
.
SON
,
document_class
=
SON
,
**
kwargs
),
db
...
...
@@ -43,7 +43,7 @@ class MongoContentStore(ContentStore):
self
.
fs_files
=
_db
[
bucket
+
".files"
]
# the underlying collection GridFS uses
def
save
(
self
,
content
):
content_id
=
content
.
get_id
(
)
content_id
=
self
.
asset_db_key
(
content
.
location
)
# Seems like with the GridFS we can't update existing ID's we have to do a delete/add pair
self
.
delete
(
content_id
)
...
...
@@ -71,13 +71,6 @@ class MongoContentStore(ContentStore):
def
find
(
self
,
location
,
throw_on_not_found
=
True
,
as_stream
=
False
):
content_id
=
self
.
asset_db_key
(
location
)
fs_pointer
=
self
.
fs_files
.
find_one
(
content_id
,
fields
=
{
'_id'
:
1
})
if
fs_pointer
is
None
:
if
throw_on_not_found
:
raise
NotFoundError
()
else
:
return
None
content_id
=
fs_pointer
[
'_id'
]
try
:
if
as_stream
:
...
...
@@ -104,13 +97,13 @@ class MongoContentStore(ContentStore):
)
except
NoFile
:
if
throw_on_not_found
:
raise
NotFoundError
()
raise
NotFoundError
(
content_id
)
else
:
return
None
def
get_stream
(
self
,
location
):
content_id
=
self
.
asset_db_key
(
location
)
fs_pointer
=
self
.
fs_files
.
find_one
(
content_id
,
fields
=
{
'_id'
:
1
})
fs_pointer
=
self
.
fs_files
.
find_one
(
{
'_id'
:
content_id
}
,
fields
=
{
'_id'
:
1
})
try
:
handle
=
self
.
fs
.
get
(
fs_pointer
[
'_id'
])
...
...
@@ -246,10 +239,10 @@ class MongoContentStore(ContentStore):
raise
AttributeError
(
"{} is a protected attribute."
.
format
(
attr
))
asset_db_key
=
self
.
asset_db_key
(
location
)
# FIXME remove fetch and use a form of update which fails if doesn't exist
item
=
self
.
fs_files
.
find_one
(
asset_db_key
)
item
=
self
.
fs_files
.
find_one
(
{
'_id'
:
asset_db_key
}
)
if
item
is
None
:
raise
NotFoundError
(
asset_db_key
)
self
.
fs_files
.
update
(
asset_db_key
,
{
"$set"
:
attr_dict
})
self
.
fs_files
.
update
(
{
'_id'
:
asset_db_key
}
,
{
"$set"
:
attr_dict
})
def
get_attrs
(
self
,
location
):
"""
...
...
@@ -262,7 +255,7 @@ class MongoContentStore(ContentStore):
:param location: a c4x asset location
"""
asset_db_key
=
self
.
asset_db_key
(
location
)
item
=
self
.
fs_files
.
find_one
(
asset_db_key
)
item
=
self
.
fs_files
.
find_one
(
{
'_id'
:
asset_db_key
}
)
if
item
is
None
:
raise
NotFoundError
(
asset_db_key
)
return
item
...
...
lms/djangoapps/courseware/tests/test_video_handlers.py
View file @
acc02b0e
...
...
@@ -67,8 +67,7 @@ def _clear_assets(location):
for
asset
in
assets
:
asset_location
=
AssetLocation
.
_from_deprecated_son
(
asset
[
"_id"
],
location
.
course_key
.
run
)
del_cached_content
(
asset_location
)
mongo_id
=
asset_location
.
to_deprecated_son
()
store
.
delete
(
mongo_id
)
store
.
delete
(
asset_location
)
def
_get_subs_id
(
filename
):
...
...
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