Wrap all asset read operations.

First step in moving assets out of the contentstore (optionally).
https://openedx.atlassian.net/browse/PLAT-77
This commit is contained in:
John Eskew
2014-10-27 12:33:07 -04:00
parent 5a1df635d0
commit 786a32e7cf
6 changed files with 135 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ from django.http import (
)
from student.models import CourseEnrollment
from xmodule.contentstore.django import contentstore
from xmodule.assetstore.assetmgr import AssetManager
from xmodule.contentstore.content import StaticContent, XASSET_LOCATION_TAG
from xmodule.modulestore import InvalidLocationError
from opaque_keys import InvalidKeyError
@@ -42,7 +42,7 @@ class StaticContentServer(object):
if content is None:
# nope, not in cache, let's fetch from DB
try:
content = contentstore().find(loc, as_stream=True)
content = AssetManager.find(loc, as_stream=True)
except NotFoundError:
response = HttpResponse()
response.status_code = 404
@@ -94,7 +94,7 @@ class StaticContentServer(object):
if request.META.get('HTTP_RANGE'):
# Data from cache (StaticContent) has no easy byte management, so we use the DB instead (StaticContentStream)
if type(content) == StaticContent:
content = contentstore().find(loc, as_stream=True)
content = AssetManager.find(loc, as_stream=True)
header_value = request.META['HTTP_RANGE']
try: