diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py index 57d8c0a0a229a8cc1f558c5aa41b020e6e4ee16d..1928fd8caaeb5573d8385f2d49cf5175dca5a98b 100644 --- a/cms/djangoapps/contentstore/management/commands/import.py +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -3,10 +3,10 @@ Script for importing courseware from XML format """ from django.core.management.base import BaseCommand from django_comment_common.utils import are_permissions_roles_seeded, seed_permissions_roles -from lms.djangoapps.dashboard.git_import import DEFAULT_PYTHON_LIB_FILENAME from xmodule.contentstore.django import contentstore from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore +from xmodule.util.sandboxing import DEFAULT_PYTHON_LIB_FILENAME from xmodule.modulestore.xml_importer import import_course_from_xml diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index 60defed4ec631290c2684f8096a6fb5395dc496f..c7a03d94de64b9cbc6c5e6e066c7876096dbfede 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -1149,7 +1149,7 @@ class CourseMetadataEditingTest(CourseTestCase): self.assertEqual(tab_list, course.tabs) @patch.dict(settings.FEATURES, {'ENABLE_EDXNOTES': True}) - @patch('xmodule.util.django.get_current_request') + @patch('xmodule.util.xmodule_django.get_current_request') def test_post_settings_with_staff_not_enrolled(self, mock_request): """ Tests that we can post advance settings when course staff is not enrolled. diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index d43eeba3e58f1784b0c7d5cc8625a78db9795c25..926fce6f54ba29bf29ccb60f6e24a1c4c155b136 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -29,7 +29,7 @@ from openedx.core.lib.xblock_utils import ( wrap_xblock_aside, xblock_local_resource_url ) -from util.sandboxing import can_execute_unsafe_code, get_python_lib_zip +from xmodule.util.sandboxing import can_execute_unsafe_code, get_python_lib_zip from xblock_config.models import StudioConfig from xblock_django.user_service import DjangoXBlockUserService from xmodule.contentstore.django import contentstore diff --git a/common/djangoapps/util/tests/test_sandboxing.py b/common/djangoapps/util/tests/test_sandboxing.py index 2dd9ae6c6097837dabf3a33ede25192714124220..1a98ff751f7fa369437b10db0ff93e2df0890270 100644 --- a/common/djangoapps/util/tests/test_sandboxing.py +++ b/common/djangoapps/util/tests/test_sandboxing.py @@ -7,7 +7,7 @@ from django.test.utils import override_settings from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locator import CourseLocator, LibraryLocator -from util.sandboxing import can_execute_unsafe_code +from xmodule.util.sandboxing import can_execute_unsafe_code class SandboxingTest(TestCase): diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 2c9e73d101b6a70c1b66f9f9c0c61948090069d2..9fe0dae734b7952d594429c5d9d30a9c8cf08094 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -11,7 +11,9 @@ import dogstats_wrapper as dog_stats_api from capa import responsetypes from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.raw_module import RawDescriptor +from xmodule.contentstore.django import contentstore from xmodule.util.misc import escape_html_characters +from xmodule.util.sandboxing import get_python_lib_zip from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT, XModule, module_attr from .capa_base import CapaFields, CapaMixin, ComplexEncoder @@ -331,7 +333,6 @@ class CapaDescriptor(CapaFields, RawDescriptor): if limit_responses == 0: # Don't even start collecting answers return - capa_system = LoncapaSystem( ajax_url=None, # TODO set anonymous_student_id to the anonymous ID of the user which answered each problem @@ -341,7 +342,7 @@ class CapaDescriptor(CapaFields, RawDescriptor): anonymous_student_id=None, cache=None, can_execute_unsafe_code=lambda: None, - get_python_lib_zip=lambda: None, + get_python_lib_zip=(lambda: get_python_lib_zip(contentstore, self.runtime.course_id)), DEBUG=None, filestore=self.runtime.resources_fs, i18n=self.runtime.service(self, "i18n"), diff --git a/common/lib/xmodule/xmodule/modulestore/django.py b/common/lib/xmodule/xmodule/modulestore/django.py index 2bdad9ffa291a2241025614a8face761753e97d7..5fb1f9921f886231b63209ffaea010b0e3154a7c 100644 --- a/common/lib/xmodule/xmodule/modulestore/django.py +++ b/common/lib/xmodule/xmodule/modulestore/django.py @@ -28,7 +28,7 @@ from openedx.core.djangoapps.request_cache.middleware import RequestCache from xmodule.contentstore.django import contentstore from xmodule.modulestore.draft_and_published import BranchSettingMixin from xmodule.modulestore.mixed import MixedModuleStore -from xmodule.util.django import get_current_request_hostname +from xmodule.util.xmodule_django import get_current_request_hostname # We also may not always have the current request user (crum) module available try: diff --git a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py index 7555f909fa833db1d425ce9135bfbe666f3b79f4..5e4dbe5a5ab79314c96006230c22cf4ec21221c8 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py @@ -271,7 +271,7 @@ class ModuleStoreIsolationMixin(CacheIsolationMixin, SignalIsolationMixin): # List of modulestore signals enabled for this test. Defaults to an empty # list. The list of signals available is found on the SignalHandler class, - # in /common/lib/xmodule/xmodule/modulestore/django.py + # in /common/lib/xmodule/xmodule/modulestore/xmodule_django.py # # You must use the signal itself, and not its name. So for example: # diff --git a/common/lib/xmodule/xmodule/tests/test_utils_django.py b/common/lib/xmodule/xmodule/tests/test_utils_django.py index 29d2c4851347f23b4c83e19dcf3b7cdce17ddd39..f79d3b5a042032db7a309f76d8673d4b35c3fb3e 100644 --- a/common/lib/xmodule/xmodule/tests/test_utils_django.py +++ b/common/lib/xmodule/xmodule/tests/test_utils_django.py @@ -1,5 +1,5 @@ """Tests for methods defined in util/django.py""" -from xmodule.util.django import get_current_request, get_current_request_hostname +from xmodule.util.xmodule_django import get_current_request, get_current_request_hostname from nose.tools import assert_is_none from unittest import TestCase diff --git a/common/djangoapps/util/sandboxing.py b/common/lib/xmodule/xmodule/util/sandboxing.py similarity index 95% rename from common/djangoapps/util/sandboxing.py rename to common/lib/xmodule/xmodule/util/sandboxing.py index 9a2127be4f1fc3532934a306358fcc550a267858..b68fb75b8b8cadfa6ec30149566b9c05c6fac05a 100644 --- a/common/djangoapps/util/sandboxing.py +++ b/common/lib/xmodule/xmodule/util/sandboxing.py @@ -1,7 +1,7 @@ import re - from django.conf import settings -from lms.djangoapps.dashboard.git_import import DEFAULT_PYTHON_LIB_FILENAME + +DEFAULT_PYTHON_LIB_FILENAME = 'python_lib.zip' def can_execute_unsafe_code(course_id): diff --git a/common/lib/xmodule/xmodule/util/django.py b/common/lib/xmodule/xmodule/util/xmodule_django.py similarity index 100% rename from common/lib/xmodule/xmodule/util/django.py rename to common/lib/xmodule/xmodule/util/xmodule_django.py diff --git a/lms/djangoapps/courseware/access_utils.py b/lms/djangoapps/courseware/access_utils.py index e0def5cebd82d568503862c33e12af1bcea5ac52..1c69d88d6a10423854d07941c7e0248f89d2cb21 100644 --- a/lms/djangoapps/courseware/access_utils.py +++ b/lms/djangoapps/courseware/access_utils.py @@ -13,7 +13,7 @@ from courseware.access_response import AccessResponse, StartDateError from courseware.masquerade import is_masquerading_as_student from openedx.features.course_experience import COURSE_PRE_START_ACCESS_FLAG from student.roles import CourseBetaTesterRole -from xmodule.util.django import get_current_request_hostname +from xmodule.util.xmodule_django import get_current_request_hostname DEBUG_ACCESS = False log = getLogger(__name__) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index dd38fa8af949ef98e6ed62fc5a70dbc275dfda89..e11f9b7f1e31ab6ed25f23ec1795306544509a08 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -69,7 +69,7 @@ from track import contexts from util import milestones_helpers from util.json_request import JsonResponse from django.utils.text import slugify -from util.sandboxing import can_execute_unsafe_code, get_python_lib_zip +from xmodule.util.sandboxing import can_execute_unsafe_code, get_python_lib_zip from xblock_django.user_service import DjangoXBlockUserService from xmodule.contentstore.django import contentstore from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor diff --git a/lms/djangoapps/dashboard/git_import.py b/lms/djangoapps/dashboard/git_import.py index 347cfdec54894375c04d66742d17f6a3eb3fd118..990cfc92efda0db52ad183539ebbd5e0b9017f87 100644 --- a/lms/djangoapps/dashboard/git_import.py +++ b/lms/djangoapps/dashboard/git_import.py @@ -15,6 +15,7 @@ from django.core import management from django.core.management.base import CommandError from django.utils import timezone from django.utils.translation import ugettext_lazy as _ +from xmodule.util.sandboxing import DEFAULT_PYTHON_LIB_FILENAME from opaque_keys.edx.keys import CourseKey from dashboard.models import CourseImportLog @@ -22,7 +23,6 @@ from dashboard.models import CourseImportLog log = logging.getLogger(__name__) DEFAULT_GIT_REPO_DIR = '/edx/var/app/edxapp/course_repos' -DEFAULT_PYTHON_LIB_FILENAME = 'python_lib.zip' class GitImportError(Exception):