Importable python_lib.zip assets

Lots of plumbing to allow an asset named python_lib.zip to be imported
by jailed Python code.

This function can find the "python_lib.zip" asset, and is passed down
through ModuleSystem and LoncapaSystem so that capa problems have access
to the zipfile.
This commit is contained in:
Ned Batchelder
2014-09-08 12:32:23 -04:00
parent 43ce6421cf
commit 616bbbab4e
18 changed files with 208 additions and 14 deletions

View File

@@ -35,6 +35,7 @@ from xblock.django.request import django_to_webob_request, webob_to_django_respo
from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor
from xmodule.exceptions import NotFoundError, ProcessingError
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.contentstore.django import contentstore
from xmodule.modulestore.django import modulestore, ModuleI18nService
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.util.duedate import get_extended_due_date
@@ -50,7 +51,7 @@ from xmodule.lti_module import LTIModule
from xmodule.x_module import XModuleDescriptor
from util.json_request import JsonResponse
from util.sandboxing import can_execute_unsafe_code
from util.sandboxing import can_execute_unsafe_code, get_python_lib_zip
log = logging.getLogger(__name__)
@@ -530,6 +531,7 @@ def get_module_system_for_user(user, field_data_cache,
s3_interface=s3_interface,
cache=cache,
can_execute_unsafe_code=(lambda: can_execute_unsafe_code(course_id)),
get_python_lib_zip=(lambda: get_python_lib_zip(contentstore, course_id)),
# TODO: When we merge the descriptor and module systems, we can stop reaching into the mixologist (cpennington)
mixins=descriptor.runtime.mixologist._mixins, # pylint: disable=protected-access
wrappers=block_wrappers,