From cfcbdc01453150f1025e59c9b6a9a03ace390f4a Mon Sep 17 00:00:00 2001 From: Calen Pennington <cale@edx.org> Date: Fri, 23 May 2014 15:57:13 -0400 Subject: [PATCH] Move to OpaqueKey implementations from the external library [LMS-2757] --- .../contentstore/features/course-export.py | 2 +- .../contentstore/features/grading.py | 2 +- .../management/commands/check_course.py | 4 +- .../management/commands/clone_course.py | 4 +- .../management/commands/delete_course.py | 4 +- .../management/commands/edit_course_tabs.py | 4 +- .../commands/empty_asset_trashcan.py | 4 +- .../management/commands/export.py | 4 +- .../management/commands/git_export.py | 4 +- .../management/commands/migrate_to_split.py | 4 +- .../commands/rollback_split_course.py | 2 +- .../commands/tests/test_git_export.py | 2 +- .../management/commands/tests/test_import.py | 2 +- .../commands/tests/test_migrate_to_split.py | 2 +- .../contentstore/tests/test_contentstore.py | 4 +- .../contentstore/tests/test_course_listing.py | 2 +- .../contentstore/tests/test_crud.py | 2 +- .../contentstore/tests/test_import.py | 2 +- .../contentstore/tests/test_permissions.py | 2 +- .../tests/test_users_default_role.py | 2 +- .../contentstore/tests/test_utils.py | 2 +- cms/djangoapps/contentstore/utils.py | 2 +- cms/djangoapps/contentstore/views/assets.py | 2 +- .../contentstore/views/checklist.py | 2 +- .../contentstore/views/component.py | 2 +- cms/djangoapps/contentstore/views/course.py | 4 +- .../contentstore/views/export_git.py | 2 +- .../contentstore/views/import_export.py | 2 +- cms/djangoapps/contentstore/views/item.py | 2 +- cms/djangoapps/contentstore/views/preview.py | 2 +- cms/djangoapps/contentstore/views/tabs.py | 2 +- .../contentstore/views/tests/test_access.py | 2 +- .../contentstore/views/tests/test_assets.py | 2 +- .../views/tests/test_course_index.py | 2 +- .../views/tests/test_course_updates.py | 2 +- .../contentstore/views/tests/test_item.py | 4 +- .../views/tests/test_transcripts.py | 2 +- .../contentstore/views/transcripts_ajax.py | 2 +- cms/djangoapps/contentstore/views/user.py | 2 +- common/djangoapps/contentserver/tests/test.py | 2 +- .../course_groups/tests/test_cohorts.py | 2 +- common/djangoapps/course_groups/views.py | 2 +- common/djangoapps/course_modes/admin.py | 4 +- .../course_modes/tests/test_models.py | 2 +- common/djangoapps/course_modes/views.py | 2 +- .../djangoapps/django_comment_common/tests.py | 4 +- common/djangoapps/embargo/forms.py | 4 +- .../djangoapps/embargo/tests/test_models.py | 2 +- .../external_auth/tests/test_shib.py | 2 +- .../external_auth/tests/test_ssl.py | 4 +- .../reverification/tests/factories.py | 2 +- .../test/test_static_replace.py | 2 +- .../commands/anonymized_id_mapping.py | 2 +- .../management/commands/change_enrollment.py | 4 +- .../commands/create_random_users.py | 4 +- .../management/commands/create_user.py | 4 +- .../student/management/commands/get_grades.py | 4 +- .../management/commands/transfer_students.py | 2 +- .../student/migrations/0035_access_roles.py | 2 +- .../migrations/0036_access_roles_orgless.py | 2 +- common/djangoapps/student/models.py | 4 +- common/djangoapps/student/tests/test_authz.py | 2 +- .../student/tests/test_auto_auth.py | 2 +- .../student/tests/test_bulk_email_settings.py | 2 +- common/djangoapps/student/tests/test_login.py | 2 +- common/djangoapps/student/tests/test_roles.py | 2 +- common/djangoapps/student/tests/tests.py | 2 +- common/djangoapps/student/views.py | 2 +- common/djangoapps/terrain/steps.py | 2 +- common/djangoapps/track/contexts.py | 2 +- common/djangoapps/user_api/middleware.py | 2 +- common/djangoapps/user_api/tests/factories.py | 2 +- .../user_api/tests/test_user_service.py | 2 +- .../djangoapps/user_api/tests/test_views.py | 2 +- common/djangoapps/user_api/views.py | 2 +- common/djangoapps/util/request.py | 2 +- .../djangoapps/util/tests/test_sandboxing.py | 2 +- common/djangoapps/xmodule_django/models.py | 2 +- common/lib/xmodule/setup.py | 15 +- .../xmodule/xmodule/contentstore/content.py | 2 +- .../lib/xmodule/xmodule/contentstore/mongo.py | 2 +- common/lib/xmodule/xmodule/course_module.py | 2 +- .../xmodule/xmodule/modulestore/__init__.py | 6 +- .../lib/xmodule/xmodule/modulestore/keys.py | 157 -------- .../xmodule/modulestore/loc_mapper_store.py | 4 +- .../xmodule/xmodule/modulestore/locations.py | 356 ------------------ .../xmodule/xmodule/modulestore/locator.py | 2 +- .../lib/xmodule/xmodule/modulestore/mixed.py | 6 +- .../xmodule/xmodule/modulestore/mongo/base.py | 2 +- .../xmodule/modulestore/mongo/draft.py | 2 +- .../xmodule/modulestore/mongoengine_fields.py | 4 +- .../split_mongo/caching_descriptor_system.py | 2 +- .../split_mongo/definition_lazy_loader.py | 2 +- .../xmodule/modulestore/split_mongo/split.py | 2 +- .../xmodule/modulestore/tests/factories.py | 2 +- .../modulestore/tests/test_location.py | 197 ---------- .../modulestore/tests/test_location_mapper.py | 4 +- .../modulestore/tests/test_locators.py | 6 +- .../tests/test_mixed_modulestore.py | 4 +- .../modulestore/tests/test_modulestore.py | 2 +- .../xmodule/modulestore/tests/test_mongo.py | 2 +- .../tests/test_split_modulestore.py | 2 +- .../tests/test_split_w_old_mongo.py | 2 +- .../xmodule/modulestore/tests/test_xml.py | 2 +- .../modulestore/tests/test_xml_importer.py | 2 +- common/lib/xmodule/xmodule/modulestore/xml.py | 4 +- .../xmodule/modulestore/xml_importer.py | 2 +- .../peer_grading_service.py | 2 +- common/lib/xmodule/xmodule/tests/__init__.py | 2 +- .../xmodule/xmodule/tests/test_conditional.py | 2 +- .../lib/xmodule/xmodule/tests/test_content.py | 2 +- .../xmodule/tests/test_course_module.py | 2 +- .../xmodule/tests/test_editing_module.py | 2 +- .../xmodule/tests/test_error_module.py | 2 +- .../lib/xmodule/xmodule/tests/test_import.py | 2 +- .../xmodule/tests/test_import_static.py | 2 +- .../xmodule/tests/test_peer_grading.py | 2 +- common/lib/xmodule/xmodule/tests/test_tabs.py | 2 +- .../lib/xmodule/xmodule/tests/xml/__init__.py | 2 +- common/lib/xmodule/xmodule/x_module.py | 31 +- docs/en_us/developers/source/modulestore.rst | 22 -- lms/djangoapps/analytics/tests/test_basic.py | 2 +- .../analytics/tests/test_distributions.py | 2 +- lms/djangoapps/bulk_email/forms.py | 4 +- .../bulk_email/tests/test_err_handling.py | 2 +- lms/djangoapps/bulk_email/tests/test_forms.py | 2 +- .../bulk_email/tests/test_models.py | 2 +- lms/djangoapps/bulk_email/tests/test_tasks.py | 2 +- .../management/commands/cert_whitelist.py | 4 +- .../management/commands/gen_cert_report.py | 4 +- .../management/commands/ungenerated_certs.py | 4 +- lms/djangoapps/certificates/views.py | 2 +- lms/djangoapps/class_dashboard/views.py | 2 +- lms/djangoapps/course_wiki/tests/tests.py | 2 +- lms/djangoapps/course_wiki/views.py | 2 +- lms/djangoapps/courseware/access.py | 2 +- lms/djangoapps/courseware/courses.py | 2 +- lms/djangoapps/courseware/features/common.py | 2 +- .../courseware/features/navigation.py | 2 +- .../commands/dump_course_structure.py | 2 +- .../management/commands/export_course.py | 2 +- .../commands/tests/test_dump_course.py | 2 +- lms/djangoapps/courseware/model_data.py | 2 +- lms/djangoapps/courseware/module_render.py | 2 +- lms/djangoapps/courseware/tests/factories.py | 2 +- lms/djangoapps/courseware/tests/test_about.py | 2 +- .../courseware/tests/test_access.py | 2 +- .../courseware/tests/test_courses.py | 2 +- .../tests/test_draft_modulestore.py | 2 +- .../courseware/tests/test_grades.py | 2 +- .../courseware/tests/test_masquerade.py | 2 +- .../courseware/tests/test_module_render.py | 2 +- lms/djangoapps/courseware/tests/test_tabs.py | 2 +- .../courseware/tests/test_video_handlers.py | 2 +- .../courseware/tests/test_video_mongo.py | 2 +- lms/djangoapps/courseware/tests/test_views.py | 2 +- lms/djangoapps/courseware/tests/tests.py | 2 +- lms/djangoapps/courseware/views.py | 2 +- lms/djangoapps/dashboard/git_import.py | 4 +- .../commands/tests/test_git_add_course.py | 4 +- lms/djangoapps/dashboard/sysadmin.py | 2 +- .../dashboard/tests/test_sysadmin.py | 2 +- .../django_comment_client/base/views.py | 4 +- .../django_comment_client/forum/views.py | 2 +- .../commands/get_discussion_link.py | 4 +- .../commands/seed_permissions_roles.py | 2 +- .../django_comment_client/permissions.py | 2 +- .../tests/test_models.py | 2 +- lms/djangoapps/django_comment_client/utils.py | 2 +- lms/djangoapps/foldit/tests.py | 2 +- lms/djangoapps/instructor/hint_manager.py | 2 +- .../management/commands/compute_grades.py | 4 +- .../management/commands/dump_grades.py | 4 +- .../management/commands/openended_post.py | 2 +- .../management/commands/openended_stats.py | 2 +- .../tests/test_openended_commands.py | 2 +- lms/djangoapps/instructor/tests/test_api.py | 2 +- lms/djangoapps/instructor/tests/test_email.py | 2 +- .../instructor/tests/test_enrollment.py | 2 +- .../instructor/tests/test_legacy_anon_csv.py | 2 +- .../tests/test_legacy_download_csv.py | 2 +- .../tests/test_legacy_forum_admin.py | 2 +- lms/djangoapps/instructor/tests/test_tools.py | 2 +- lms/djangoapps/instructor/views/api.py | 2 +- .../instructor/views/instructor_dashboard.py | 2 +- lms/djangoapps/instructor/views/legacy.py | 4 +- lms/djangoapps/instructor_task/api_helper.py | 2 +- .../instructor_task/tests/factories.py | 2 +- .../instructor_task/tests/test_base.py | 2 +- .../instructor_task/tests/test_tasks.py | 2 +- .../commands/generate_serial_numbers.py | 2 +- .../commands/import_serial_numbers.py | 2 +- lms/djangoapps/licenses/views.py | 2 +- lms/djangoapps/notes/api.py | 2 +- lms/djangoapps/notes/tests.py | 2 +- .../staff_grading_service.py | 2 +- lms/djangoapps/open_ended_grading/tests.py | 2 +- lms/djangoapps/open_ended_grading/views.py | 2 +- .../shoppingcart/tests/test_models.py | 2 +- lms/djangoapps/shoppingcart/views.py | 2 +- lms/djangoapps/staticbook/views.py | 2 +- .../verify_student/tests/test_models.py | 2 +- .../verify_student/tests/test_views.py | 2 +- lms/djangoapps/verify_student/views.py | 2 +- lms/lib/xblock/test/test_runtime.py | 2 +- requirements/edx/github.txt | 2 +- 206 files changed, 271 insertions(+), 991 deletions(-) delete mode 100644 common/lib/xmodule/xmodule/modulestore/keys.py delete mode 100644 common/lib/xmodule/xmodule/modulestore/locations.py delete mode 100644 common/lib/xmodule/xmodule/modulestore/tests/test_location.py diff --git a/cms/djangoapps/contentstore/features/course-export.py b/cms/djangoapps/contentstore/features/course-export.py index 580e582f5df..2f428d5bd2d 100644 --- a/cms/djangoapps/contentstore/features/course-export.py +++ b/cms/djangoapps/contentstore/features/course-export.py @@ -5,7 +5,7 @@ from lettuce import world, step from component_settings_editor_helpers import enter_xml_in_advanced_problem from nose.tools import assert_true, assert_equal -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from contentstore.utils import reverse_usage_url diff --git a/cms/djangoapps/contentstore/features/grading.py b/cms/djangoapps/contentstore/features/grading.py index 14a11b79653..862d2f2462f 100644 --- a/cms/djangoapps/contentstore/features/grading.py +++ b/cms/djangoapps/contentstore/features/grading.py @@ -5,7 +5,7 @@ from lettuce import world, step from common import * from terrain.steps import reload_the_page from selenium.common.exceptions import InvalidElementStateException -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from contentstore.utils import reverse_course_url from nose.tools import assert_in, assert_not_in, assert_equal, assert_not_equal # pylint: disable=E0611 diff --git a/cms/djangoapps/contentstore/management/commands/check_course.py b/cms/djangoapps/contentstore/management/commands/check_course.py index 292139c0549..45bbcad78a4 100644 --- a/cms/djangoapps/contentstore/management/commands/check_course.py +++ b/cms/djangoapps/contentstore/management/commands/check_course.py @@ -1,9 +1,9 @@ from django.core.management.base import BaseCommand, CommandError from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_importer import check_module_metadata_editability -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/cms/djangoapps/contentstore/management/commands/clone_course.py b/cms/djangoapps/contentstore/management/commands/clone_course.py index 20d34a2d8a0..1f982994209 100644 --- a/cms/djangoapps/contentstore/management/commands/clone_course.py +++ b/cms/djangoapps/contentstore/management/commands/clone_course.py @@ -6,9 +6,9 @@ from xmodule.modulestore.store_utilities import clone_course from xmodule.modulestore.django import modulestore from xmodule.contentstore.django import contentstore from student.roles import CourseInstructorRole, CourseStaffRole -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey # diff --git a/cms/djangoapps/contentstore/management/commands/delete_course.py b/cms/djangoapps/contentstore/management/commands/delete_course.py index 6a842123e58..89e88b9f9d5 100644 --- a/cms/djangoapps/contentstore/management/commands/delete_course.py +++ b/cms/djangoapps/contentstore/management/commands/delete_course.py @@ -4,9 +4,9 @@ from django.core.management.base import BaseCommand, CommandError from .prompt import query_yes_no from contentstore.utils import delete_course_and_groups -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py b/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py index 0d08390e762..65d45bf0b20 100644 --- a/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py +++ b/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py @@ -14,8 +14,8 @@ from courseware.courses import get_course_by_id from contentstore.views import tabs from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey def print_course(course): diff --git a/cms/djangoapps/contentstore/management/commands/empty_asset_trashcan.py b/cms/djangoapps/contentstore/management/commands/empty_asset_trashcan.py index 1b5ec5bba67..c28e752c847 100644 --- a/cms/djangoapps/contentstore/management/commands/empty_asset_trashcan.py +++ b/cms/djangoapps/contentstore/management/commands/empty_asset_trashcan.py @@ -1,10 +1,10 @@ from django.core.management.base import BaseCommand, CommandError from xmodule.contentstore.utils import empty_asset_trashcan from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from .prompt import query_yes_no from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/cms/djangoapps/contentstore/management/commands/export.py b/cms/djangoapps/contentstore/management/commands/export.py index 212ce7b5f0e..c2408080cbb 100644 --- a/cms/djangoapps/contentstore/management/commands/export.py +++ b/cms/djangoapps/contentstore/management/commands/export.py @@ -6,10 +6,10 @@ import os from django.core.management.base import BaseCommand, CommandError from xmodule.modulestore.xml_exporter import export_to_xml from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from xmodule.contentstore.django import contentstore from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/cms/djangoapps/contentstore/management/commands/git_export.py b/cms/djangoapps/contentstore/management/commands/git_export.py index 066b7b8cbcb..1bc7f18337d 100644 --- a/cms/djangoapps/contentstore/management/commands/git_export.py +++ b/cms/djangoapps/contentstore/management/commands/git_export.py @@ -20,10 +20,10 @@ from django.core.management.base import BaseCommand, CommandError from django.utils.translation import ugettext as _ import contentstore.git_export_utils as git_export_utils -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys import InvalidKeyError from contentstore.git_export_utils import GitExportError -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey log = logging.getLogger(__name__) diff --git a/cms/djangoapps/contentstore/management/commands/migrate_to_split.py b/cms/djangoapps/contentstore/management/commands/migrate_to_split.py index 0cedb6a9240..ede707079f2 100644 --- a/cms/djangoapps/contentstore/management/commands/migrate_to_split.py +++ b/cms/djangoapps/contentstore/management/commands/migrate_to_split.py @@ -7,9 +7,9 @@ from django.contrib.auth.models import User from xmodule.modulestore.django import modulestore from xmodule.modulestore.split_migrator import SplitMigrator from xmodule.modulestore.django import loc_mapper -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey def user_from_str(identifier): diff --git a/cms/djangoapps/contentstore/management/commands/rollback_split_course.py b/cms/djangoapps/contentstore/management/commands/rollback_split_course.py index 3c191427d40..46273c05895 100644 --- a/cms/djangoapps/contentstore/management/commands/rollback_split_course.py +++ b/cms/djangoapps/contentstore/management/commands/rollback_split_course.py @@ -5,7 +5,7 @@ is to delete the course from the split mongo datastore. from django.core.management.base import BaseCommand, CommandError from xmodule.modulestore.django import modulestore, loc_mapper from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.locator import CourseLocator +from opaque_keys.edx.locator import CourseLocator class Command(BaseCommand): diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py index 33eee8a9582..5166e1aaf60 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py @@ -18,7 +18,7 @@ from django.test.utils import override_settings from contentstore.tests.utils import CourseTestCase import contentstore.git_export_utils as git_export_utils from contentstore.git_export_utils import GitExportError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey FEATURES_WITH_EXPORT_GIT = settings.FEATURES.copy() FEATURES_WITH_EXPORT_GIT['ENABLE_EXPORT_GIT'] = True diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_import.py b/cms/djangoapps/contentstore/management/commands/tests/test_import.py index ed09923c85c..a051dd1e9d2 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_import.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_import.py @@ -14,7 +14,7 @@ from contentstore.tests.modulestore_config import TEST_MODULESTORE from django_comment_common.utils import are_permissions_roles_seeded from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_MODULESTORE) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py index cbdcde47aa5..70aa4e370c6 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py @@ -11,7 +11,7 @@ from contentstore.tests.modulestore_config import TEST_MODULESTORE from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.django import modulestore, clear_existing_modulestores -from xmodule.modulestore.locator import CourseLocator +from opaque_keys.edx.locator import CourseLocator # pylint: disable=E1101 diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 2eb8967c1b0..79a4a4178d9 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -33,8 +33,8 @@ from xmodule.modulestore import mongo from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.inheritance import own_metadata -from xmodule.modulestore.keys import UsageKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey, AssetLocation +from opaque_keys.edx.keys import UsageKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from xmodule.modulestore.store_utilities import clone_course, delete_course from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory diff --git a/cms/djangoapps/contentstore/tests/test_course_listing.py b/cms/djangoapps/contentstore/tests/test_course_listing.py index e25ae735ebf..fb5da5cee52 100644 --- a/cms/djangoapps/contentstore/tests/test_course_listing.py +++ b/cms/djangoapps/contentstore/tests/test_course_listing.py @@ -16,7 +16,7 @@ from student.roles import CourseInstructorRole, CourseStaffRole from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey TOTAL_COURSES_COUNT = 500 USER_COURSES_COUNT = 50 diff --git a/cms/djangoapps/contentstore/tests/test_crud.py b/cms/djangoapps/contentstore/tests/test_crud.py index 7ffcaff06d3..58b0291d498 100644 --- a/cms/djangoapps/contentstore/tests/test_crud.py +++ b/cms/djangoapps/contentstore/tests/test_crud.py @@ -6,7 +6,7 @@ from xmodule.course_module import CourseDescriptor from xmodule.modulestore.django import modulestore, loc_mapper, clear_existing_modulestores from xmodule.seq_module import SequenceDescriptor from xmodule.capa_module import CapaDescriptor -from xmodule.modulestore.locator import BlockUsageLocator, LocalId +from opaque_keys.edx.locator import BlockUsageLocator, LocalId from xmodule.modulestore.exceptions import ItemNotFoundError, DuplicateCourseError from xmodule.html_module import HtmlDescriptor from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/cms/djangoapps/contentstore/tests/test_import.py b/cms/djangoapps/contentstore/tests/test_import.py index cf11196cb28..bd31e5b5854 100644 --- a/cms/djangoapps/contentstore/tests/test_import.py +++ b/cms/djangoapps/contentstore/tests/test_import.py @@ -17,7 +17,7 @@ from contentstore.tests.modulestore_config import TEST_MODULESTORE from xmodule.modulestore.django import modulestore from xmodule.contentstore.django import contentstore -from xmodule.modulestore.locations import SlashSeparatedCourseKey, AssetLocation +from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from xmodule.modulestore.xml_importer import import_from_xml from xmodule.contentstore.content import StaticContent from xmodule.contentstore.django import _CONTENTSTORE diff --git a/cms/djangoapps/contentstore/tests/test_permissions.py b/cms/djangoapps/contentstore/tests/test_permissions.py index afa357a9cd7..3a07718dfa3 100644 --- a/cms/djangoapps/contentstore/tests/test_permissions.py +++ b/cms/djangoapps/contentstore/tests/test_permissions.py @@ -9,7 +9,7 @@ from django.contrib.auth.models import User from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from contentstore.tests.modulestore_config import TEST_MODULESTORE from contentstore.tests.utils import AjaxEnabledTestClient -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from contentstore.utils import reverse_url, reverse_course_url from student.roles import CourseInstructorRole, CourseStaffRole from contentstore.views.access import has_course_access diff --git a/cms/djangoapps/contentstore/tests/test_users_default_role.py b/cms/djangoapps/contentstore/tests/test_users_default_role.py index 4621d72f026..b5928d594ba 100644 --- a/cms/djangoapps/contentstore/tests/test_users_default_role.py +++ b/cms/djangoapps/contentstore/tests/test_users_default_role.py @@ -7,7 +7,7 @@ from contentstore.utils import delete_course_and_groups, reverse_url from courseware.tests.factories import UserFactory from xmodule.modulestore import Location from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.models import CourseEnrollment diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index c10a03e87e9..8d7ac3c97a5 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -8,7 +8,7 @@ from django.test.utils import override_settings from contentstore import utils from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class LMSLinksTestCase(TestCase): diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 9ceb68d8d55..f18176b8553 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -12,7 +12,7 @@ from xmodule.contentstore.content import StaticContent from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from xmodule.modulestore.store_utilities import delete_course from student.roles import CourseInstructorRole, CourseStaffRole diff --git a/cms/djangoapps/contentstore/views/assets.py b/cms/djangoapps/contentstore/views/assets.py index de9a6784c54..9cedef0cffa 100644 --- a/cms/djangoapps/contentstore/views/assets.py +++ b/cms/djangoapps/contentstore/views/assets.py @@ -19,7 +19,7 @@ from xmodule.modulestore.django import modulestore from xmodule.contentstore.content import StaticContent from xmodule.exceptions import NotFoundError from django.core.exceptions import PermissionDenied -from xmodule.modulestore.keys import CourseKey, AssetKey +from opaque_keys.edx.keys import CourseKey, AssetKey from util.date_utils import get_default_time_display from util.json_request import JsonResponse diff --git a/cms/djangoapps/contentstore/views/checklist.py b/cms/djangoapps/contentstore/views/checklist.py index ba326c6e64b..1f86a11e715 100644 --- a/cms/djangoapps/contentstore/views/checklist.py +++ b/cms/djangoapps/contentstore/views/checklist.py @@ -9,7 +9,7 @@ from django_future.csrf import ensure_csrf_cookie from edxmako.shortcuts import render_to_response from django.http import HttpResponseNotFound from django.core.exceptions import PermissionDenied -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.django import modulestore from contentstore.utils import get_modulestore, reverse_course_url diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index ef582c13736..0093aaed7b8 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -25,7 +25,7 @@ from contentstore.utils import get_lms_link_for_item, compute_publish_state, Pub from contentstore.views.helpers import get_parent_xblock from models.settings.course_grading import CourseGradingModel -from xmodule.modulestore.keys import UsageKey +from opaque_keys.edx.keys import UsageKey from .access import has_course_access from django.utils.translation import ugettext as _ diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 4f7667db726..4a94a1f0fcb 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -23,7 +23,7 @@ from xmodule.tabs import PDFTextbookTabs from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import Location, SlashSeparatedCourseKey +from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey from contentstore.course_info_model import get_course_updates, update_course_updates, delete_course_update from contentstore.utils import ( @@ -53,7 +53,7 @@ from django_comment_common.utils import seed_permissions_roles from student.models import CourseEnrollment from student.roles import CourseRole, UserBasedRole -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from course_creators.views import get_course_creator_status, add_user_with_status_unrequested from contentstore import utils from student.roles import CourseInstructorRole, CourseStaffRole, CourseCreatorRole, GlobalStaff diff --git a/cms/djangoapps/contentstore/views/export_git.py b/cms/djangoapps/contentstore/views/export_git.py index 82c0b874e70..94edd13018a 100644 --- a/cms/djangoapps/contentstore/views/export_git.py +++ b/cms/djangoapps/contentstore/views/export_git.py @@ -14,7 +14,7 @@ from .access import has_course_access import contentstore.git_export_utils as git_export_utils from edxmako.shortcuts import render_to_response from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey log = logging.getLogger(__name__) diff --git a/cms/djangoapps/contentstore/views/import_export.py b/cms/djangoapps/contentstore/views/import_export.py index ffc161c4b4f..f4e226cffcf 100644 --- a/cms/djangoapps/contentstore/views/import_export.py +++ b/cms/djangoapps/contentstore/views/import_export.py @@ -24,7 +24,7 @@ from edxmako.shortcuts import render_to_response from xmodule.contentstore.django import contentstore from xmodule.exceptions import SerializationError from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.xml_exporter import export_to_xml diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index bdbe64b4441..bbb6f30bdd1 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -38,7 +38,7 @@ from contentstore.views.preview import get_preview_fragment from edxmako.shortcuts import render_to_string from models.settings.course_grading import CourseGradingModel from cms.lib.xblock.runtime import handler_url, local_resource_url -from xmodule.modulestore.keys import UsageKey, CourseKey +from opaque_keys.edx.keys import UsageKey, CourseKey __all__ = ['orphan_handler', 'xblock_handler', 'xblock_view_handler'] diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 0a2139a80c5..5b0ef4fa48a 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -13,7 +13,7 @@ from xmodule_modifiers import replace_static_urls, wrap_xblock, wrap_fragment from xmodule.error_module import ErrorDescriptor from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.modulestore.django import modulestore, ModuleI18nService -from xmodule.modulestore.keys import UsageKey +from opaque_keys.edx.keys import UsageKey from xmodule.x_module import ModuleSystem from xblock.runtime import KvsFieldData from xblock.django.request import webob_to_django_response, django_to_webob_request diff --git a/cms/djangoapps/contentstore/views/tabs.py b/cms/djangoapps/contentstore/views/tabs.py index b6243783d89..e69a3d177fc 100644 --- a/cms/djangoapps/contentstore/views/tabs.py +++ b/cms/djangoapps/contentstore/views/tabs.py @@ -13,7 +13,7 @@ from django.views.decorators.http import require_http_methods from edxmako.shortcuts import render_to_response from xmodule.modulestore.django import modulestore from xmodule.tabs import CourseTabList, StaticTab, CourseTab, InvalidTabsException -from xmodule.modulestore.keys import CourseKey, UsageKey +from opaque_keys.edx.keys import CourseKey, UsageKey from ..utils import get_lms_link_for_item diff --git a/cms/djangoapps/contentstore/views/tests/test_access.py b/cms/djangoapps/contentstore/views/tests/test_access.py index 70e14771864..755607d0cc6 100644 --- a/cms/djangoapps/contentstore/views/tests/test_access.py +++ b/cms/djangoapps/contentstore/views/tests/test_access.py @@ -8,7 +8,7 @@ from student.roles import CourseInstructorRole, CourseStaffRole from student.tests.factories import AdminFactory from student.auth import add_users from contentstore.views.access import get_user_role -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class RolesTest(TestCase): diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index 76bf33ee9af..aeec07b3789 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -18,7 +18,7 @@ from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_importer import import_from_xml from django.test.utils import override_settings -from xmodule.modulestore.locations import SlashSeparatedCourseKey, AssetLocation +from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation class AssetsTestCase(CourseTestCase): diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index 861c2a88628..36033e7b791 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -7,7 +7,7 @@ import lxml from contentstore.tests.utils import CourseTestCase from contentstore.utils import reverse_course_url from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory -from xmodule.modulestore.locator import Locator +from opaque_keys.edx.locator import Locator class TestCourseIndex(CourseTestCase): diff --git a/cms/djangoapps/contentstore/views/tests/test_course_updates.py b/cms/djangoapps/contentstore/views/tests/test_course_updates.py index 1fb8716b469..1ffcedfff46 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_updates.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_updates.py @@ -5,7 +5,7 @@ import json from contentstore.tests.test_course_settings import CourseTestCase from contentstore.utils import reverse_course_url, reverse_usage_url -from xmodule.modulestore.locations import Location, SlashSeparatedCourseKey +from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey from xmodule.modulestore.django import modulestore diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index 4a6ffc54e41..dd11ef0d069 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -22,8 +22,8 @@ from student.tests.factories import UserFactory from xmodule.capa_module import CapaDescriptor from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.keys import UsageKey -from xmodule.modulestore.locations import Location +from opaque_keys.edx.keys import UsageKey +from opaque_keys.edx.locations import Location class ItemTest(CourseTestCase): diff --git a/cms/djangoapps/contentstore/views/tests/test_transcripts.py b/cms/djangoapps/contentstore/views/tests/test_transcripts.py index c9447371738..1cbe8a59d0e 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcripts.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcripts.py @@ -18,7 +18,7 @@ from xmodule.modulestore.django import modulestore from xmodule.contentstore.django import contentstore, _CONTENTSTORE from xmodule.contentstore.content import StaticContent from xmodule.exceptions import NotFoundError -from xmodule.modulestore.keys import UsageKey +from opaque_keys.edx.keys import UsageKey from xmodule.video_module import transcripts_utils from contentstore.tests.modulestore_config import TEST_MODULESTORE diff --git a/cms/djangoapps/contentstore/views/transcripts_ajax.py b/cms/djangoapps/contentstore/views/transcripts_ajax.py index 3ccb656b90c..d3a0add4b7e 100644 --- a/cms/djangoapps/contentstore/views/transcripts_ajax.py +++ b/cms/djangoapps/contentstore/views/transcripts_ajax.py @@ -22,7 +22,7 @@ from opaque_keys import InvalidKeyError from xmodule.contentstore.content import StaticContent from xmodule.exceptions import NotFoundError from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import UsageKey +from opaque_keys.edx.keys import UsageKey from xmodule.contentstore.django import contentstore from xmodule.modulestore.exceptions import ItemNotFoundError diff --git a/cms/djangoapps/contentstore/views/user.py b/cms/djangoapps/contentstore/views/user.py index 0d51fe3ff1c..b316de987e7 100644 --- a/cms/djangoapps/contentstore/views/user.py +++ b/cms/djangoapps/contentstore/views/user.py @@ -8,7 +8,7 @@ from django_future.csrf import ensure_csrf_cookie from edxmako.shortcuts import render_to_response from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from util.json_request import JsonResponse, expect_json from student.roles import CourseInstructorRole, CourseStaffRole from course_creators.views import user_requested_access diff --git a/common/djangoapps/contentserver/tests/test.py b/common/djangoapps/contentserver/tests/test.py index 21666b6f233..d562b301463 100644 --- a/common/djangoapps/contentserver/tests/test.py +++ b/common/djangoapps/contentserver/tests/test.py @@ -17,7 +17,7 @@ from student.models import CourseEnrollment from xmodule.contentstore.django import contentstore, _CONTENTSTORE from xmodule.contentstore.content import StaticContent from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.tests.django_utils import (studio_store_config, ModuleStoreTestCase) from xmodule.modulestore.xml_importer import import_from_xml diff --git a/common/djangoapps/course_groups/tests/test_cohorts.py b/common/djangoapps/course_groups/tests/test_cohorts.py index 4901bdc94a4..497839674c0 100644 --- a/common/djangoapps/course_groups/tests/test_cohorts.py +++ b/common/djangoapps/course_groups/tests/test_cohorts.py @@ -9,7 +9,7 @@ from course_groups.cohorts import (get_cohort, get_course_cohorts, is_commentable_cohorted, get_cohort_by_name) from xmodule.modulestore.django import modulestore, clear_existing_modulestores -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.tests.django_utils import mixed_store_config diff --git a/common/djangoapps/course_groups/views.py b/common/djangoapps/course_groups/views.py index ca30973c19b..1341b47cb9f 100644 --- a/common/djangoapps/course_groups/views.py +++ b/common/djangoapps/course_groups/views.py @@ -8,7 +8,7 @@ import json import logging import re -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.courses import get_course_with_access from edxmako.shortcuts import render_to_response diff --git a/common/djangoapps/course_modes/admin.py b/common/djangoapps/course_modes/admin.py index ad6ec016cea..ced2bca3b84 100644 --- a/common/djangoapps/course_modes/admin.py +++ b/common/djangoapps/course_modes/admin.py @@ -4,8 +4,8 @@ from django import forms from opaque_keys import InvalidKeyError from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class CourseModeForm(forms.ModelForm): diff --git a/common/djangoapps/course_modes/tests/test_models.py b/common/djangoapps/course_modes/tests/test_models.py index c29a9e7ec3d..7e47a3645dd 100644 --- a/common/djangoapps/course_modes/tests/test_models.py +++ b/common/djangoapps/course_modes/tests/test_models.py @@ -8,7 +8,7 @@ Replace this with more appropriate tests for your application. from datetime import datetime, timedelta import pytz -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.test import TestCase from course_modes.models import CourseMode, Mode diff --git a/common/djangoapps/course_modes/views.py b/common/djangoapps/course_modes/views.py index 018dba5e7b0..2d7155a6799 100644 --- a/common/djangoapps/course_modes/views.py +++ b/common/djangoapps/course_modes/views.py @@ -20,7 +20,7 @@ from courseware.access import has_access from student.models import CourseEnrollment from student.views import course_from_id from verify_student.models import SoftwareSecurePhotoVerification -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class ChooseModeView(View): diff --git a/common/djangoapps/django_comment_common/tests.py b/common/djangoapps/django_comment_common/tests.py index 308a1c93906..158f8836c94 100644 --- a/common/djangoapps/django_comment_common/tests.py +++ b/common/djangoapps/django_comment_common/tests.py @@ -1,6 +1,6 @@ from django.test import TestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django_comment_common.models import Role from student.models import CourseEnrollment, User @@ -37,7 +37,7 @@ class RoleAssignmentTest(TestCase): # The following was written on the assumption that unenrolling from a course # should remove all forum Roles for that student for that course. This is - # not necessarily the case -- please see comments at the top of + # not necessarily the case -- please see comments at the top of # django_comment_client.models.assign_default_role(). Leaving it for the # forums team to sort out. # diff --git a/common/djangoapps/embargo/forms.py b/common/djangoapps/embargo/forms.py index e4cd740a0ce..c5904520af2 100644 --- a/common/djangoapps/embargo/forms.py +++ b/common/djangoapps/embargo/forms.py @@ -11,8 +11,8 @@ import ipaddr from xmodule.modulestore.django import modulestore from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class EmbargoedCourseForm(forms.ModelForm): # pylint: disable=incomplete-protocol diff --git a/common/djangoapps/embargo/tests/test_models.py b/common/djangoapps/embargo/tests/test_models.py index ac63f8d4333..b6ad918a66f 100644 --- a/common/djangoapps/embargo/tests/test_models.py +++ b/common/djangoapps/embargo/tests/test_models.py @@ -1,7 +1,7 @@ """Test of models for embargo middleware app""" from django.test import TestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from embargo.models import EmbargoedCourse, EmbargoedState, IPFilter diff --git a/common/djangoapps/external_auth/tests/test_shib.py b/common/djangoapps/external_auth/tests/test_shib.py index 49ffc6e638c..5bdc2d04155 100644 --- a/common/djangoapps/external_auth/tests/test_shib.py +++ b/common/djangoapps/external_auth/tests/test_shib.py @@ -19,7 +19,7 @@ from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, mixed_store_config from xmodule.modulestore.inheritance import own_metadata from xmodule.modulestore.django import editable_modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from external_auth.models import ExternalAuthMap from external_auth.views import shib_login, course_specific_login, course_specific_register, _flatten_to_ascii diff --git a/common/djangoapps/external_auth/tests/test_ssl.py b/common/djangoapps/external_auth/tests/test_ssl.py index 21cfa04e5a3..c601f8bdada 100644 --- a/common/djangoapps/external_auth/tests/test_ssl.py +++ b/common/djangoapps/external_auth/tests/test_ssl.py @@ -207,7 +207,7 @@ class SSLClientTest(ModuleStoreTestCase): # Expect an InvalidKeyError from course page as we don't have anything else built with self.assertRaisesRegexp( InvalidKeyError, - "<class 'xmodule.modulestore.keys.CourseKey'>: None" + "<class 'opaque_keys.edx.keys.CourseKey'>: None" ): self.client.get( reverse('signup'), follow=True, @@ -219,7 +219,7 @@ class SSLClientTest(ModuleStoreTestCase): # Now that we are logged in, make sure we don't see the registration page with self.assertRaisesRegexp( InvalidKeyError, - "<class 'xmodule.modulestore.keys.CourseKey'>: None" + "<class 'opaque_keys.edx.keys.CourseKey'>: None" ): self.client.get(reverse('signup'), follow=True) diff --git a/common/djangoapps/reverification/tests/factories.py b/common/djangoapps/reverification/tests/factories.py index 65669c6b085..58684d97f01 100644 --- a/common/djangoapps/reverification/tests/factories.py +++ b/common/djangoapps/reverification/tests/factories.py @@ -5,7 +5,7 @@ from reverification.models import MidcourseReverificationWindow from factory.django import DjangoModelFactory import pytz from datetime import timedelta, datetime -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey # Factories don't have __init__ methods, and are self documenting diff --git a/common/djangoapps/static_replace/test/test_static_replace.py b/common/djangoapps/static_replace/test/test_static_replace.py index e7f67961959..7dc3d7f3cb1 100644 --- a/common/djangoapps/static_replace/test/test_static_replace.py +++ b/common/djangoapps/static_replace/test/test_static_replace.py @@ -5,7 +5,7 @@ from static_replace import (replace_static_urls, replace_course_urls, _url_replace_regex) from mock import patch, Mock -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.mongo import MongoModuleStore from xmodule.modulestore.xml import XMLModuleStore diff --git a/common/djangoapps/student/management/commands/anonymized_id_mapping.py b/common/djangoapps/student/management/commands/anonymized_id_mapping.py index 363c3e74bec..d7707cb738a 100644 --- a/common/djangoapps/student/management/commands/anonymized_id_mapping.py +++ b/common/djangoapps/student/management/commands/anonymized_id_mapping.py @@ -14,7 +14,7 @@ from django.contrib.auth.models import User from django.core.management.base import BaseCommand, CommandError from student.models import anonymous_id_for_user -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/common/djangoapps/student/management/commands/change_enrollment.py b/common/djangoapps/student/management/commands/change_enrollment.py index 001745f1df5..62ce9e37796 100644 --- a/common/djangoapps/student/management/commands/change_enrollment.py +++ b/common/djangoapps/student/management/commands/change_enrollment.py @@ -3,8 +3,8 @@ from opaque_keys import InvalidKeyError from optparse import make_option from student.models import CourseEnrollment, User -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/common/djangoapps/student/management/commands/create_random_users.py b/common/djangoapps/student/management/commands/create_random_users.py index 000ebd2ac1e..5ad55db7beb 100644 --- a/common/djangoapps/student/management/commands/create_random_users.py +++ b/common/djangoapps/student/management/commands/create_random_users.py @@ -4,8 +4,8 @@ A script to create some dummy users from django.core.management.base import BaseCommand from student.models import CourseEnrollment from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.views import _do_create_account, get_random_post_override diff --git a/common/djangoapps/student/management/commands/create_user.py b/common/djangoapps/student/management/commands/create_user.py index 9ba00cabdaf..2da0a6e4fa8 100644 --- a/common/djangoapps/student/management/commands/create_user.py +++ b/common/djangoapps/student/management/commands/create_user.py @@ -6,8 +6,8 @@ from django.core.management.base import BaseCommand from django.utils import translation from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.models import CourseEnrollment, Registration, create_comments_service_user from student.views import _do_create_account, AccountValidationError from track.management.tracked_command import TrackedCommand diff --git a/common/djangoapps/student/management/commands/get_grades.py b/common/djangoapps/student/management/commands/get_grades.py index a3857e8e9ec..2d9dc859b57 100644 --- a/common/djangoapps/student/management/commands/get_grades.py +++ b/common/djangoapps/student/management/commands/get_grades.py @@ -8,8 +8,8 @@ from django.test.client import RequestFactory from django.core.management.base import BaseCommand, CommandError import os from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.contrib.auth.models import User from optparse import make_option import datetime diff --git a/common/djangoapps/student/management/commands/transfer_students.py b/common/djangoapps/student/management/commands/transfer_students.py index 3a77c325a77..c1b46cdeff2 100644 --- a/common/djangoapps/student/management/commands/transfer_students.py +++ b/common/djangoapps/student/management/commands/transfer_students.py @@ -3,7 +3,7 @@ from django.core.management.base import BaseCommand from django.contrib.auth.models import User from student.models import CourseEnrollment from shoppingcart.models import CertificateItem -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/common/djangoapps/student/migrations/0035_access_roles.py b/common/djangoapps/student/migrations/0035_access_roles.py index ca85f90ed58..3dc6d7d2143 100644 --- a/common/djangoapps/student/migrations/0035_access_roles.py +++ b/common/djangoapps/student/migrations/0035_access_roles.py @@ -4,7 +4,7 @@ from south.v2 import DataMigration from django.db import models from xmodule.modulestore.django import loc_mapper import re -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys import InvalidKeyError import bson.son import logging diff --git a/common/djangoapps/student/migrations/0036_access_roles_orgless.py b/common/djangoapps/student/migrations/0036_access_roles_orgless.py index 176a3902ace..de01eee0d64 100644 --- a/common/djangoapps/student/migrations/0036_access_roles_orgless.py +++ b/common/djangoapps/student/migrations/0036_access_roles_orgless.py @@ -2,7 +2,7 @@ from south.v2 import DataMigration from xmodule.modulestore.django import loc_mapper, modulestore import re -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys import InvalidKeyError import logging from django.db.models.query_utils import Q diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index e002d7f1a10..3ebaa053bb8 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -34,13 +34,13 @@ from track import contexts from eventtracking import tracker from importlib import import_module -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from course_modes.models import CourseMode import lms.lib.comment_client as cc from util.query import use_read_replica_if_available from xmodule_django.models import CourseKeyField, NoneToEmptyManager -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from functools import total_ordering unenroll_done = Signal(providing_args=["course_enrollment"]) diff --git a/common/djangoapps/student/tests/test_authz.py b/common/djangoapps/student/tests/test_authz.py index 24d8c085da5..fcd5a33c775 100644 --- a/common/djangoapps/student/tests/test_authz.py +++ b/common/djangoapps/student/tests/test_authz.py @@ -10,7 +10,7 @@ from django.core.exceptions import PermissionDenied from student.roles import CourseInstructorRole, CourseStaffRole, CourseCreatorRole from student.tests.factories import AdminFactory from student.auth import has_access, add_users, remove_users -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class CreatorGroupTest(TestCase): diff --git a/common/djangoapps/student/tests/test_auto_auth.py b/common/djangoapps/student/tests/test_auto_auth.py index 6228962d0b8..6692b336fac 100644 --- a/common/djangoapps/student/tests/test_auto_auth.py +++ b/common/djangoapps/student/tests/test_auto_auth.py @@ -6,7 +6,7 @@ from django_comment_common.models import ( from django_comment_common.utils import seed_permissions_roles from student.models import CourseEnrollment, UserProfile from util.testing import UrlResetMixin -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from mock import patch diff --git a/common/djangoapps/student/tests/test_bulk_email_settings.py b/common/djangoapps/student/tests/test_bulk_email_settings.py index f164aea7618..5965807897a 100644 --- a/common/djangoapps/student/tests/test_bulk_email_settings.py +++ b/common/djangoapps/student/tests/test_bulk_email_settings.py @@ -15,7 +15,7 @@ from student.tests.factories import UserFactory, CourseEnrollmentFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from bulk_email.models import CourseAuthorization diff --git a/common/djangoapps/student/tests/test_login.py b/common/djangoapps/student/tests/test_login.py index 00fc67282ae..7d3201ca8be 100644 --- a/common/djangoapps/student/tests/test_login.py +++ b/common/djangoapps/student/tests/test_login.py @@ -20,7 +20,7 @@ from xmodule.modulestore.inheritance import own_metadata from xmodule.modulestore.django import editable_modulestore from external_auth.models import ExternalAuthMap -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey TEST_DATA_MIXED_MODULESTORE = mixed_store_config(settings.COMMON_TEST_DATA_ROOT, {}) diff --git a/common/djangoapps/student/tests/test_roles.py b/common/djangoapps/student/tests/test_roles.py index c5d6acdabd3..cef4d7997b6 100644 --- a/common/djangoapps/student/tests/test_roles.py +++ b/common/djangoapps/student/tests/test_roles.py @@ -9,7 +9,7 @@ from student.tests.factories import AnonymousUserFactory from student.roles import GlobalStaff, CourseRole, CourseStaffRole, OrgStaffRole, OrgInstructorRole, \ CourseInstructorRole -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class RolesTestCase(TestCase): diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index b0caef85b40..c5845ac8bc4 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -21,7 +21,7 @@ from unittest.case import SkipTest from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from courseware.tests.tests import TEST_DATA_MIXED_MODULESTORE -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from mock import Mock, patch diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 661bb9763e4..39a3449ed10 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -52,7 +52,7 @@ from dark_lang.models import DarkLangConfig from xmodule.course_module import CourseDescriptor from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore import XML_MODULESTORE_TYPE, Location from collections import namedtuple diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index d96e093e673..32dc4db4322 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -21,7 +21,7 @@ from .course_helpers import * from .ui_helpers import * from nose.tools import assert_equals # pylint: disable=E0611 -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from logging import getLogger logger = getLogger(__name__) diff --git a/common/djangoapps/track/contexts.py b/common/djangoapps/track/contexts.py index bb8673480e3..07b2cbdbdb6 100644 --- a/common/djangoapps/track/contexts.py +++ b/common/djangoapps/track/contexts.py @@ -1,7 +1,7 @@ """Generates common contexts""" import logging -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys import InvalidKeyError from util.request import COURSE_REGEX diff --git a/common/djangoapps/user_api/middleware.py b/common/djangoapps/user_api/middleware.py index 97387e50072..97dc7d4bba3 100644 --- a/common/djangoapps/user_api/middleware.py +++ b/common/djangoapps/user_api/middleware.py @@ -5,7 +5,7 @@ Adds user's tags to tracking event context. from track.contexts import COURSE_REGEX from eventtracking import tracker from user_api.models import UserCourseTag -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class UserTagsEventContextMiddleware(object): diff --git a/common/djangoapps/user_api/tests/factories.py b/common/djangoapps/user_api/tests/factories.py index e5bd4debac6..8d32f171428 100644 --- a/common/djangoapps/user_api/tests/factories.py +++ b/common/djangoapps/user_api/tests/factories.py @@ -3,7 +3,7 @@ from factory.django import DjangoModelFactory from factory import SubFactory from student.tests.factories import UserFactory from user_api.models import UserPreference, UserCourseTag -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey # Factories don't have __init__ methods, and are self documenting # pylint: disable=W0232, C0111 diff --git a/common/djangoapps/user_api/tests/test_user_service.py b/common/djangoapps/user_api/tests/test_user_service.py index 63be81b049d..366a2cb27b7 100644 --- a/common/djangoapps/user_api/tests/test_user_service.py +++ b/common/djangoapps/user_api/tests/test_user_service.py @@ -5,7 +5,7 @@ from django.test import TestCase from student.tests.factories import UserFactory from user_api import user_service -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class TestUserService(TestCase): diff --git a/common/djangoapps/user_api/tests/test_views.py b/common/djangoapps/user_api/tests/test_views.py index 2cc187599e4..ddebd1e5f4c 100644 --- a/common/djangoapps/user_api/tests/test_views.py +++ b/common/djangoapps/user_api/tests/test_views.py @@ -9,7 +9,7 @@ from unittest import SkipTest from user_api.models import UserPreference from user_api.tests.factories import UserPreferenceFactory from django_comment_common import models -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey TEST_API_KEY = "test_api_key" diff --git a/common/djangoapps/user_api/views.py b/common/djangoapps/user_api/views.py index c75db2e177d..d007d7a9aa1 100644 --- a/common/djangoapps/user_api/views.py +++ b/common/djangoapps/user_api/views.py @@ -11,7 +11,7 @@ from rest_framework.response import Response from user_api.serializers import UserSerializer, UserPreferenceSerializer from user_api.models import UserPreference from django_comment_common.models import Role -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class ApiKeyHeaderPermission(permissions.BasePermission): diff --git a/common/djangoapps/util/request.py b/common/djangoapps/util/request.py index b3b369cff4e..3192261bfae 100644 --- a/common/djangoapps/util/request.py +++ b/common/djangoapps/util/request.py @@ -3,7 +3,7 @@ import re from django.conf import settings from microsite_configuration import microsite -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey COURSE_REGEX = re.compile(r'^.*?/courses/(?P<course_id>[^/]+/[^/]+/[^/]+)') diff --git a/common/djangoapps/util/tests/test_sandboxing.py b/common/djangoapps/util/tests/test_sandboxing.py index 55daa6681cc..7a33fbbe952 100644 --- a/common/djangoapps/util/tests/test_sandboxing.py +++ b/common/djangoapps/util/tests/test_sandboxing.py @@ -5,7 +5,7 @@ Tests for sandboxing.py in util app from django.test import TestCase from util.sandboxing import can_execute_unsafe_code from django.test.utils import override_settings -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class SandboxingTest(TestCase): diff --git a/common/djangoapps/xmodule_django/models.py b/common/djangoapps/xmodule_django/models.py index 4ea96442fab..4d1d27a765b 100644 --- a/common/djangoapps/xmodule_django/models.py +++ b/common/djangoapps/xmodule_django/models.py @@ -1,6 +1,6 @@ from django.db import models from django.core.exceptions import ValidationError -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from south.modelsinspector import add_introspection_rules add_introspection_rules([], ["^xmodule_django\.models\.CourseKeyField"]) diff --git a/common/lib/xmodule/setup.py b/common/lib/xmodule/setup.py index 7cd306b0265..5182a8454c7 100644 --- a/common/lib/xmodule/setup.py +++ b/common/lib/xmodule/setup.py @@ -55,6 +55,7 @@ setup( 'capa', 'path.py', 'webob', + 'opaque-keys', ], package_data={ 'xmodule': ['js/module/*'], @@ -68,19 +69,5 @@ setup( 'console_scripts': [ 'xmodule_assets = xmodule.static_content:main', ], - 'course_key': [ - 'slashes = xmodule.modulestore.locations:SlashSeparatedCourseKey', - 'course-locator = xmodule.modulestore.locator:CourseLocator', - ], - 'usage_key': [ - 'location = xmodule.modulestore.locations:Location', - 'edx = xmodule.modulestore.locator:BlockUsageLocator', - ], - 'asset_key': [ - 'asset-location = xmodule.modulestore.locations:AssetLocation', - ], - 'definition_key': [ - 'defx = xmodule.modulestore.locator:DefinitionLocator', - ], }, ) diff --git a/common/lib/xmodule/xmodule/contentstore/content.py b/common/lib/xmodule/xmodule/contentstore/content.py index 69a115f898c..31fb55a73c6 100644 --- a/common/lib/xmodule/xmodule/contentstore/content.py +++ b/common/lib/xmodule/xmodule/contentstore/content.py @@ -10,7 +10,7 @@ import StringIO from urlparse import urlparse, urlunparse, parse_qsl from urllib import urlencode -from xmodule.modulestore.locations import AssetLocation, SlashSeparatedCourseKey +from opaque_keys.edx.locations import AssetLocation, SlashSeparatedCourseKey from .django import contentstore from PIL import Image diff --git a/common/lib/xmodule/xmodule/contentstore/mongo.py b/common/lib/xmodule/xmodule/contentstore/mongo.py index 9cad2f10146..2f388f4d8dd 100644 --- a/common/lib/xmodule/xmodule/contentstore/mongo.py +++ b/common/lib/xmodule/xmodule/contentstore/mongo.py @@ -13,7 +13,7 @@ from fs.osfs import OSFS import os import json import bson.son -from xmodule.modulestore.locations import AssetLocation +from opaque_keys.edx.locations import AssetLocation class MongoContentStore(ContentStore): diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index f8df19fa162..c1e0baf5aac 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -17,7 +17,7 @@ import json from xblock.fields import Scope, List, String, Dict, Boolean, Integer from .fields import Date -from xmodule.modulestore.locator import CourseLocator +from opaque_keys.edx.locator import CourseLocator from django.utils.timezone import UTC log = logging.getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 10816823f87..5b66049373a 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -14,10 +14,10 @@ from xblock.plugin import default_select from .exceptions import InvalidLocationError, InsufficientSpecificationError from xmodule.errortracker import make_error_tracker -from xmodule.modulestore.keys import CourseKey, UsageKey -from xmodule.modulestore.locations import Location # For import backwards compatibility +from opaque_keys.edx.keys import CourseKey, UsageKey +from opaque_keys.edx.locations import Location # For import backwards compatibility from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xblock.runtime import Mixologist from xblock.core import XBlock import datetime diff --git a/common/lib/xmodule/xmodule/modulestore/keys.py b/common/lib/xmodule/xmodule/modulestore/keys.py deleted file mode 100644 index 3f4a04872bd..00000000000 --- a/common/lib/xmodule/xmodule/modulestore/keys.py +++ /dev/null @@ -1,157 +0,0 @@ -""" -OpaqueKey abstract classes for edx-platform object types (courses, definitions, usages, and assets). -""" -from abc import abstractmethod, abstractproperty - -from opaque_keys import OpaqueKey -from xblock.runtime import IdReader - - -class CourseKey(OpaqueKey): - """ - An :class:`opaque_keys.OpaqueKey` identifying a particular Course object. - """ - KEY_TYPE = 'course_key' - __slots__ = () - - @abstractproperty - def org(self): - """ - The organization that this course belongs to. - """ - raise NotImplementedError() - - @abstractproperty - def offering(self): - """ - The offering identifier for this course. - - This is complement of the org; in old-style IDs, "course/run" - """ - raise NotImplementedError() - - @abstractmethod - def make_usage_key(self, block_type, block_id): - """ - Return a usage key, given the given the specified block_type and block_id. - - This function should not actually create any new ids, but should simply - return one that already exists. - """ - raise NotImplementedError() - - @abstractmethod - def make_asset_key(self, asset_type, path): - """ - Return an asset key, given the given the specified path. - - This function should not actually create any new ids, but should simply - return one that already exists. - """ - raise NotImplementedError() - - -class DefinitionKey(OpaqueKey): - """ - An :class:`opaque_keys.OpaqueKey` identifying an XBlock definition. - """ - KEY_TYPE = 'definition_key' - __slots__ = () - - @abstractproperty - def block_type(self): - """ - The XBlock type of this definition. - """ - raise NotImplementedError() - - -class CourseObjectMixin(object): - """ - An abstract :class:`opaque_keys.OpaqueKey` mixin - for keys that belong to courses. - """ - __slots__ = () - - @abstractproperty - def course_key(self): - """ - Return the :class:`CourseKey` for the course containing this usage. - """ - raise NotImplementedError() - - @abstractmethod - def map_into_course(self, course_key): - """ - Return a new :class:`UsageKey` or :class:`AssetKey` representing this usage inside the - course identified by the supplied :class:`CourseKey`. It returns the same type as - `self` - - Args: - course_key (:class:`CourseKey`): The course to map this object into. - - Returns: - A new :class:`CourseObjectMixin` instance. - """ - raise NotImplementedError() - - -class AssetKey(CourseObjectMixin, OpaqueKey): - """ - An :class:`opaque_keys.OpaqueKey` identifying a course asset. - """ - KEY_TYPE = 'asset_key' - __slots__ = () - - @abstractproperty - def path(self): - """ - Return the path for this asset. - """ - raise NotImplementedError() - - -class UsageKey(CourseObjectMixin, OpaqueKey): - """ - An :class:`opaque_keys.OpaqueKey` identifying an XBlock usage. - """ - KEY_TYPE = 'usage_key' - __slots__ = () - - @abstractproperty - def definition_key(self): - """ - Return the :class:`DefinitionKey` for the XBlock containing this usage. - """ - raise NotImplementedError() - - @property - def block_type(self): - return self.category - - -class OpaqueKeyReader(IdReader): - """ - IdReader for :class:`DefinitionKey` and :class:`UsageKey`s. - """ - def get_definition_id(self, usage_id): - """Retrieve the definition that a usage is derived from. - - Args: - usage_id: The id of the usage to query - - Returns: - The `definition_id` the usage is derived from - """ - return usage_id.definition_key - - def get_block_type(self, def_id): - """Retrieve the block_type of a particular definition - - Args: - def_id: The id of the definition to query - - Returns: - The `block_type` of the definition - """ - return def_id.block_type diff --git a/common/lib/xmodule/xmodule/modulestore/loc_mapper_store.py b/common/lib/xmodule/xmodule/modulestore/loc_mapper_store.py index 1c9d10c624b..7ac332dd3f2 100644 --- a/common/lib/xmodule/xmodule/modulestore/loc_mapper_store.py +++ b/common/lib/xmodule/xmodule/modulestore/loc_mapper_store.py @@ -8,8 +8,8 @@ import bson.son import urllib from xmodule.modulestore.exceptions import InvalidLocationError, ItemNotFoundError -from xmodule.modulestore.locator import BlockUsageLocator, CourseLocator -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator +from opaque_keys.edx.locations import SlashSeparatedCourseKey class LocMapperStore(object): diff --git a/common/lib/xmodule/xmodule/modulestore/locations.py b/common/lib/xmodule/xmodule/modulestore/locations.py deleted file mode 100644 index 973c7f2c7cc..00000000000 --- a/common/lib/xmodule/xmodule/modulestore/locations.py +++ /dev/null @@ -1,356 +0,0 @@ -"""OpaqueKey implementations used by XML and Mongo modulestores""" - -import logging -import re -from bson.son import SON - -from opaque_keys import InvalidKeyError, OpaqueKey - -from xmodule.modulestore.keys import CourseKey, UsageKey, DefinitionKey, AssetKey -import json - -log = logging.getLogger(__name__) - -URL_RE = re.compile(""" - ([^:/]+://?|/[^/]+) - (?P<org>[^/]+)/ - (?P<course>[^/]+)/ - (?P<category>[^/]+)/ - (?P<name>[^@]+) - (@(?P<revision>[^/]+))? - """, re.VERBOSE) - -# TODO (cpennington): We should decide whether we want to expand the -# list of valid characters in a location -INVALID_CHARS = re.compile(r"[^\w.%-]", re.UNICODE) -# Names are allowed to have colons. -INVALID_CHARS_NAME = re.compile(r"[^\w.:%-]", re.UNICODE) - -# html ids can contain word chars and dashes -INVALID_HTML_CHARS = re.compile(r"[^\w-]", re.UNICODE) - - -class SlashSeparatedCourseKey(CourseKey): - """Course key for old style org/course/run course identifiers""" - - CANONICAL_NAMESPACE = 'slashes' - KEY_FIELDS = ('org', 'course', 'run') - __slots__ = KEY_FIELDS - - def __init__(self, org, course, run): - """ - checks that the values are syntactically valid before creating object - """ - for part in (org, course, run): - LocationBase._check_location_part(part, INVALID_CHARS) - super(SlashSeparatedCourseKey, self).__init__(org, course, run) - - @classmethod - def _from_string(cls, serialized): - serialized = serialized.replace("+", "/") - if serialized.count('/') != 2: - raise InvalidKeyError(cls, serialized) - - # Turns encoded slashes into actual slashes - return cls(*serialized.split('/')) - - def _to_string(self): - # Turns slashes into pluses - return u'+'.join([self.org, self.course, self.run]) - - @property - def offering(self): - return u'/'.join([self.course, self.run]) - - def make_asset_key(self, asset_type, path): - return AssetLocation(self.org, self.course, self.run, asset_type, path, None) - - def make_usage_key(self, block_type, name): - return Location(self.org, self.course, self.run, block_type, name, None) - - def to_deprecated_string(self): - return u'/'.join([self.org, self.course, self.run]) - - @classmethod - def from_deprecated_string(cls, serialized): - return cls._from_string(serialized) - - def make_usage_key_from_deprecated_string(self, location_url): - """ - Temporary mechanism for creating a UsageKey given a CourseKey and a serialized Location. NOTE: - this prejudicially takes the tag, org, and course from the url not self. - - Raises: - InvalidKeyError: if the url does not parse - """ - match = URL_RE.match(location_url) - if match is None: - raise InvalidKeyError(Location, location_url) - groups = match.groupdict() - return Location(run=self.run, **groups) - - -class LocationBase(object): - """ - Encodes a type of Location, which identifies a piece of - content situated in a course. - """ - KEY_FIELDS = ('org', 'course', 'run', 'category', 'name', 'revision') - - SERIALIZED_PATTERN = re.compile(""" - (?P<org>[^/]+)\+ - (?P<course>[^/]+)\+ - (?P<run>[^/]+)\+ - (?P<category>[^/]+)\+ - (?P<name>[^@/]+) - (@(?P<revision>[^/]+))? - """, re.VERBOSE) - - @classmethod - def _check_location_part(cls, val, regexp): - """ - Check that `regexp` doesn't match inside `val`. If it does, raise an exception - - Args: - val (string): The value to check - regexp (re.RegexObject): The regular expression specifying invalid characters - - Raises: - InvalidKeyError: Raised if any invalid character is found in `val` - """ - if val is None: - return - - if not isinstance(val, basestring): - raise InvalidKeyError(cls, "{!r} is not a string".format(val)) - - if regexp.search(val) is not None: - raise InvalidKeyError(cls, "Invalid characters in {!r}.".format(val)) - - @classmethod - def _clean(cls, value, invalid): - """ - invalid should be a compiled regexp of chars to replace with '_' - """ - return re.sub('_+', '_', invalid.sub('_', value)) - - @classmethod - def clean(cls, value): - """ - Return value, made into a form legal for locations - """ - return cls._clean(value, INVALID_CHARS) - - @classmethod - def clean_keeping_underscores(cls, value): - """ - Return value, replacing INVALID_CHARS, but not collapsing multiple '_' chars. - This for cleaning asset names, as the YouTube ID's may have underscores in them, and we need the - transcript asset name to match. In the future we may want to change the behavior of _clean. - """ - return INVALID_CHARS.sub('_', value) - - @classmethod - def clean_for_url_name(cls, value): - """ - Convert value into a format valid for location names (allows colons). - """ - return cls._clean(value, INVALID_CHARS_NAME) - - @classmethod - def clean_for_html(cls, value): - """ - Convert a string into a form that's safe for use in html ids, classes, urls, etc. - Replaces all INVALID_HTML_CHARS with '_', collapses multiple '_' chars - """ - return cls._clean(value, INVALID_HTML_CHARS) - - def __init__(self, org, course, run, category, name, revision=None): - """ - Create a new Location that is a clone of the specifed one. - - Components must be composed of alphanumeric characters, or the - characters '_', '-', and '.'. The name component is additionally allowed to have ':', - which is interpreted specially for xml storage. - - Components may be set to None, which may be interpreted in some contexts - to mean wildcard selection. - """ - # check that the values are syntactically valid before creating object - for part in (org, course, run, category, revision): - self._check_location_part(part, INVALID_CHARS) - self._check_location_part(name, INVALID_CHARS_NAME) - - # call the OpaqueKey constructor ensuring the args in the same order as KEY_FIELDS above - super(LocationBase, self).__init__(org, course, run, category, name, revision) - - @property - def tag(self): - return self.DEPRECATED_TAG - - @property - def definition_key(self): - # Locations are both UsageKeys and DefinitionKeys - return self - - @property - def block_type(self): - return self.category - - @classmethod - def from_deprecated_string(cls, serialized): - match = URL_RE.match(serialized) - if match is None: - raise InvalidKeyError(Location, serialized) - groups = match.groupdict() - return cls(run=None, **groups) - - def to_deprecated_string(self): - url = u"{0.DEPRECATED_TAG}://{0.org}/{0.course}/{0.category}/{0.name}".format(self) - if self.revision: - url += u"@{rev}".format(rev=self.revision) # pylint: disable=E1101 - return url - - def _to_string(self): - output = u"+".join( - unicode(val) - for val in (self.org, self.course, self.run, self.category, self.name) - ) - if self.revision: - output += u'@{}'.format(self.revision) - return output - - @classmethod - def _from_string(cls, serialized): - match = cls.SERIALIZED_PATTERN.match(serialized) - if not match: - raise InvalidKeyError(cls, serialized) - - return cls(**match.groupdict()) - - def html_id(self): - """ - Return a string with a version of the location that is safe for use in - html id attributes - """ - id_fields = [self.DEPRECATED_TAG, self.org, self.course, self.category, self.name, self.revision] - id_string = u"-".join([v for v in id_fields if v is not None]) - return Location.clean_for_html(id_string) - - @property - def course_key(self): - return SlashSeparatedCourseKey(self.org, self.course, self.run) - - def to_deprecated_son(self, prefix='', tag='i4x'): - """ - Returns a SON object that represents this location - """ - # adding tag b/c deprecated form used it - son = SON({prefix + 'tag': tag}) - for field_name in self.KEY_FIELDS: - # Temporary filtering of run field because deprecated form left it out - if field_name != 'run': - son[prefix + field_name] = getattr(self, field_name) - return son - - @classmethod - def _from_deprecated_son(cls, id_dict, run): - """ - Return the Location decoding this id_dict and run - """ - return cls(id_dict['org'], id_dict['course'], run, id_dict['category'], id_dict['name'], id_dict['revision']) - - -class Location(LocationBase, UsageKey, DefinitionKey): - """ - UsageKey and DefinitionKey implementation class for use with - XML and Mongo modulestores. - """ - - CANONICAL_NAMESPACE = 'location' - DEPRECATED_TAG = 'i4x' - __slots__ = LocationBase.KEY_FIELDS - - def map_into_course(self, course_key): - """ - Return a new :class:`UsageKey` representing this usage inside the - course identified by the supplied :class:`CourseKey`. - - Args: - course_key (CourseKey): The course to map this object into. - - Returns: - A new :class:`CourseObjectMixin` instance. - """ - return Location(course_key.org, course_key.course, course_key.run, self.category, self.name, self.revision) - - -class AssetLocation(LocationBase, AssetKey): - """ - An AssetKey implementation class. - """ - CANONICAL_NAMESPACE = 'asset-location' - DEPRECATED_TAG = 'c4x' - __slots__ = LocationBase.KEY_FIELDS - - def __init__(self, org, course, run, category, name, revision=None): - super(AssetLocation, self).__init__(org, course, run, category, name, revision) - - @property - def path(self): - return self.name - - def to_deprecated_string(self): - url = u"/{0.DEPRECATED_TAG}/{0.org}/{0.course}/{0.category}/{0.name}".format(self) - return url - - ASSET_URL_RE = re.compile(r""" - /?c4x/ - (?P<org>[^/]+)/ - (?P<course>[^/]+)/ - (?P<category>[^/]+)/ - (?P<name>[^/]+) - """, re.VERBOSE | re.IGNORECASE) - - @classmethod - def from_deprecated_string(cls, serialized): - match = cls.ASSET_URL_RE.match(serialized) - if match is None: - raise InvalidKeyError(Location, serialized) - groups = match.groupdict() - return cls(run=None, **groups) - - def map_into_course(self, course_key): - """ - Return a new :class:`UsageKey` representing this usage inside the - course identified by the supplied :class:`CourseKey`. - - Args: - course_key (CourseKey): The course to map this object into. - - Returns: - A new :class:`CourseObjectMixin` instance. - """ - return AssetLocation(course_key.org, course_key.course, course_key.run, self.category, self.name, self.revision) - - def to_deprecated_list_repr(self): - """ - Thumbnail locations are stored as lists [c4x, org, course, thumbnail, path, None] in contentstore.mongo - That should be the only use of this method, but the method is general enough to provide the pre-opaque - Location fields as an array in the old order with the tag. - """ - return ['c4x', self.org, self.course, self.block_type, self.name, None] - - -class i4xEncoder(json.JSONEncoder): - """ - If provided as the cls to json.dumps, will serialize and Locations as i4x strings and other - keys using the unicode strings. - """ - def default(self, key): - if isinstance(key, OpaqueKey): - if isinstance(key, (LocationBase, SlashSeparatedCourseKey)): - return key.to_deprecated_string() - else: - return unicode(key) - super(i4xEncoder, self).default(key) diff --git a/common/lib/xmodule/xmodule/modulestore/locator.py b/common/lib/xmodule/xmodule/modulestore/locator.py index 4d70656819a..b568b6e8089 100644 --- a/common/lib/xmodule/xmodule/modulestore/locator.py +++ b/common/lib/xmodule/xmodule/modulestore/locator.py @@ -13,7 +13,7 @@ from bson.errors import InvalidId from opaque_keys import OpaqueKey, InvalidKeyError -from xmodule.modulestore.keys import CourseKey, UsageKey, DefinitionKey +from opaque_keys.edx.keys import CourseKey, UsageKey, DefinitionKey log = logging.getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/modulestore/mixed.py b/common/lib/xmodule/xmodule/modulestore/mixed.py index 11f5bd88ab5..814f6816fb5 100644 --- a/common/lib/xmodule/xmodule/modulestore/mixed.py +++ b/common/lib/xmodule/xmodule/modulestore/mixed.py @@ -12,12 +12,12 @@ from opaque_keys import InvalidKeyError from . import ModuleStoreWriteBase from xmodule.modulestore.django import create_modulestore_instance, loc_mapper from xmodule.modulestore import Location, XML_MODULESTORE_TYPE -from xmodule.modulestore.locator import CourseLocator, Locator, BlockUsageLocator +from opaque_keys.edx.locator import CourseLocator, Locator, BlockUsageLocator from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.keys import CourseKey, UsageKey +from opaque_keys.edx.keys import CourseKey, UsageKey from xmodule.modulestore.mongo.base import MongoModuleStore from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index cbffc85d89c..4af77850287 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -36,7 +36,7 @@ from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationErr from xmodule.modulestore.inheritance import own_metadata, InheritanceMixin, inherit_metadata, InheritanceKeyValueStore from xmodule.tabs import StaticTab, CourseTabList from xblock.core import XBlock -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py index 8c2888669cc..2d5d26592ca 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py @@ -13,7 +13,7 @@ from pytz import UTC from xmodule.exceptions import InvalidVersionError from xmodule.modulestore.exceptions import ItemNotFoundError, DuplicateItemError from xmodule.modulestore.mongo.base import MongoModuleStore -from xmodule.modulestore.locations import Location +from opaque_keys.edx.locations import Location DRAFT = 'draft' # Things w/ these categories should never be marked as version='draft' diff --git a/common/lib/xmodule/xmodule/modulestore/mongoengine_fields.py b/common/lib/xmodule/xmodule/modulestore/mongoengine_fields.py index 59953192eb9..670ab64bd3e 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongoengine_fields.py +++ b/common/lib/xmodule/xmodule/modulestore/mongoengine_fields.py @@ -2,9 +2,9 @@ Custom field types for mongoengine """ import mongoengine -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from types import NoneType -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey class CourseKeyField(mongoengine.StringField): diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py index 543f5474031..7e92cd26752 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py @@ -1,7 +1,7 @@ import sys import logging from xmodule.mako_module import MakoDescriptorSystem -from xmodule.modulestore.locator import BlockUsageLocator, LocalId, CourseLocator +from opaque_keys.edx.locator import BlockUsageLocator, LocalId, CourseLocator from xmodule.error_module import ErrorDescriptor from xmodule.errortracker import exc_info_to_str from xblock.runtime import KvsFieldData diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py index cf086113799..a9b91fe4a51 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py @@ -1,4 +1,4 @@ -from xmodule.modulestore.locator import DefinitionLocator +from opaque_keys.edx.locator import DefinitionLocator class DefinitionLazyLoader(object): diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index a82d16243dd..0d16a40dde9 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -54,7 +54,7 @@ import copy from pytz import UTC from xmodule.errortracker import null_error_tracker -from xmodule.modulestore.locator import ( +from opaque_keys.edx.locator import ( BlockUsageLocator, DefinitionLocator, CourseLocator, VersionTree, LocalId, Locator ) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py index 3f1c1b78ba2..20d7252fd9e 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py @@ -3,7 +3,7 @@ from factory.containers import CyclicDefinitionError from uuid import uuid4 from xmodule.modulestore import prefer_xmodules -from xmodule.modulestore.locations import Location +from opaque_keys.edx.locations import Location from xblock.core import XBlock diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_location.py b/common/lib/xmodule/xmodule/modulestore/tests/test_location.py deleted file mode 100644 index 0a9ffd53c99..00000000000 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_location.py +++ /dev/null @@ -1,197 +0,0 @@ -""" -Thorough tests of the Location class -""" -import ddt - -from unittest import TestCase -from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import Location, AssetLocation, SlashSeparatedCourseKey - -# Pairs for testing the clean* functions. -# The first item in the tuple is the input string. -# The second item in the tuple is what the result of -# replacement should be. -GENERAL_PAIRS = [ - ('', ''), - (' ', '_'), - ('abc,', 'abc_'), - ('ab fg!@//\\aj', 'ab_fg_aj'), - (u"ab\xA9", "ab_"), # no unicode allowed for now -] - - -@ddt.ddt -class TestLocations(TestCase): - """ - Tests of :class:`.Location` - """ - @ddt.data( - "org+course+run+category+name", - "org+course+run+category+name@revision" - ) - def test_string_roundtrip(self, url): - self.assertEquals(url, Location._from_string(url)._to_string()) # pylint: disable=protected-access - - @ddt.data( - "i4x://org/course/category/name", - "i4x://org/course/category/name@revision" - ) - def test_deprecated_roundtrip(self, url): - course_id = SlashSeparatedCourseKey('org', 'course', 'run') - self.assertEquals( - url, - course_id.make_usage_key_from_deprecated_string(url).to_deprecated_string() - ) - - def test_invalid_chars_ssck(self): - """ - Test that the ssck constructor fails if given invalid chars - """ - valid_base = SlashSeparatedCourseKey(u'org.dept-1%2', u'course.sub-2%3', u'run.faster-4%5') - for key in SlashSeparatedCourseKey.KEY_FIELDS: - with self.assertRaises(InvalidKeyError): - # this ends up calling the constructor where the legality check should occur - valid_base.replace(**{key: u'funny thing'}) - - def test_invalid_chars_location(self): - """ - Test that the location constructor fails if given invalid chars - """ - course_key = SlashSeparatedCourseKey(u'org.dept-1%2', u'course.sub-2%3', u'run.faster-4%5') - valid_base = course_key.make_usage_key('tomato-again%9', 'block-head:sub-4%9') - for key in SlashSeparatedCourseKey.KEY_FIELDS: - with self.assertRaises(InvalidKeyError): - # this ends up calling the constructor where the legality check should occur - valid_base.replace(**{key: u'funny thing'}) - - @ddt.data( - ((), { - 'org': 'org', - 'course': 'course', - 'run': 'run', - 'category': 'category', - 'name': 'name', - }, 'org', 'course', 'run', 'category', 'name', None), - ((), { - 'org': 'org', - 'course': 'course', - 'run': 'run', - 'category': 'category', - 'name': 'name:more_name', - }, 'org', 'course', 'run', 'category', 'name:more_name', None), - (['org', 'course', 'run', 'category', 'name'], {}, 'org', 'course', 'run', 'category', 'name', None), - ) - @ddt.unpack - def test_valid_locations(self, args, kwargs, org, course, run, category, name, revision): - location = Location(*args, **kwargs) - self.assertEquals(org, location.org) - self.assertEquals(course, location.course) - self.assertEquals(run, location.run) - self.assertEquals(category, location.category) - self.assertEquals(name, location.name) - self.assertEquals(revision, location.revision) - - @ddt.data( - (("foo",), {}), - (["foo", "bar"], {}), - (["foo", "bar", "baz", "blat/blat", "foo"], {}), - (["foo", "bar", "baz", "blat", "foo/bar"], {}), - (["foo", "bar", "baz", "blat:blat", "foo:bar"], {}), # ':' ok in name, not in category - (('org', 'course', 'run', 'category', 'name with spaces', 'revision'), {}), - (('org', 'course', 'run', 'category', 'name/with/slashes', 'revision'), {}), - (('org', 'course', 'run', 'category', 'name', u'\xae'), {}), - (('org', 'course', 'run', 'category', u'\xae', 'revision'), {}), - ((), { - 'tag': 'tag', - 'course': 'course', - 'category': 'category', - 'name': 'name@more_name', - 'org': 'org' - }), - ((), { - 'tag': 'tag', - 'course': 'course', - 'category': 'category', - 'name': 'name ', # extra space - 'org': 'org' - }), - ) - @ddt.unpack - def test_invalid_locations(self, *args, **kwargs): - with self.assertRaises(TypeError): - Location(*args, **kwargs) - - def test_equality(self): - self.assertEquals( - Location('tag', 'org', 'course', 'run', 'category', 'name'), - Location('tag', 'org', 'course', 'run', 'category', 'name') - ) - - self.assertNotEquals( - Location('tag', 'org', 'course', 'run', 'category', 'name1'), - Location('tag', 'org', 'course', 'run', 'category', 'name') - ) - - @ddt.data( - ('a:b', 'a_b'), # no colons in non-name components - ('a-b', 'a-b'), # dashes ok - ('a.b', 'a.b'), # dot ok - *GENERAL_PAIRS - ) - def test_clean(self, pair): - self.assertEquals(Location.clean(pair[0]), pair[1]) - - @ddt.data( - ('a:b', 'a:b'), # colons ok in names - ('a-b', 'a-b'), # dashes ok in names - ('a.b', 'a.b'), # dot ok in names - *GENERAL_PAIRS - ) - def test_clean_for_url_name(self, pair): - self.assertEquals(Location.clean_for_url_name(pair[0]), pair[1]) - - @ddt.data( - ("a:b", "a_b"), # no colons for html use - ("a-b", "a-b"), # dashes ok (though need to be replaced in various use locations. ugh.) - ('a.b', 'a_b'), # no dots. - *GENERAL_PAIRS - ) - def test_clean_for_html(self, pair): - self.assertEquals(Location.clean_for_html(pair[0]), pair[1]) - - def test_html_id(self): - loc = Location('org', 'course', 'run', 'cat', 'name:more_name', 'rev') - self.assertEquals(loc.html_id(), "i4x-org-course-cat-name_more_name-rev") - - def test_replacement(self): - # pylint: disable=protected-access - - self.assertEquals( - Location('o', 'c', 'r', 'c', 'n', 'r').replace(name='new_name'), - Location('o', 'c', 'r', 'c', 'new_name', 'r'), - ) - - with self.assertRaises(InvalidKeyError): - Location('o', 'c', 'r', 'c', 'n', 'r').replace(name=u'name\xae') - - @ddt.data('org', 'course', 'category', 'name', 'revision') - def test_immutable(self, attr): - loc = Location('o', 'c', 'r', 'c', 'n', 'r') - with self.assertRaises(AttributeError): - setattr(loc, attr, attr) - - def test_map_into_course_location(self): - loc = Location('org', 'course', 'run', 'cat', 'name:more_name', 'rev') - course_key = SlashSeparatedCourseKey("edX", "toy", "2012_Fall") - self.assertEquals( - Location("edX", "toy", "2012_Fall", 'cat', 'name:more_name', 'rev'), - loc.map_into_course(course_key) - ) - - def test_map_into_course_asset_location(self): - loc = AssetLocation('org', 'course', 'run', 'asset', 'foo.bar') - course_key = SlashSeparatedCourseKey("edX", "toy", "2012_Fall") - self.assertEquals( - AssetLocation("edX", "toy", "2012_Fall", 'asset', 'foo.bar'), - loc.map_into_course(course_key) - ) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_location_mapper.py b/common/lib/xmodule/xmodule/modulestore/tests/test_location_mapper.py index 274deb014de..ad0ae22d90c 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_location_mapper.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_location_mapper.py @@ -4,11 +4,11 @@ Test the loc mapper store import unittest import uuid from xmodule.modulestore import Location -from xmodule.modulestore.locator import BlockUsageLocator, CourseLocator +from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError from xmodule.modulestore.loc_mapper_store import LocMapperStore from mock import Mock -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey import bson.son diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py b/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py index 3c60ebb3c4e..b3b571f88b2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py @@ -1,14 +1,14 @@ """ -Tests for xmodule.modulestore.locator. +Tests for opaque_keys.edx.locator. """ from unittest import TestCase import random from bson.objectid import ObjectId from opaque_keys import InvalidKeyError -from xmodule.modulestore.locator import Locator, CourseLocator, BlockUsageLocator, DefinitionLocator +from opaque_keys.edx.locator import Locator, CourseLocator, BlockUsageLocator, DefinitionLocator from ddt import ddt, data -from xmodule.modulestore.keys import UsageKey, CourseKey, DefinitionKey +from opaque_keys.edx.keys import UsageKey, CourseKey, DefinitionKey @ddt diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index 084fb7d91dd..2f2357b9426 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -9,12 +9,12 @@ from xmodule.modulestore import Location, MONGO_MODULESTORE_TYPE, SPLIT_MONGO_MO XML_MODULESTORE_TYPE from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.locator import BlockUsageLocator, CourseLocator +from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from xmodule.modulestore.tests.test_location_mapper import LocMapperSetupSansDjango, loc_mapper # Mixed modulestore depends on django, so we'll manually configure some django settings # before importing the module from django.conf import settings -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey import bson.son if not settings.configured: settings.configure() diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore.py index b53a081e50b..9de18ddceb2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore.py @@ -2,7 +2,7 @@ from nose.tools import assert_equals, assert_raises, assert_true, assert_false from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.search import path_to_location -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey def check_path_to_location(modulestore): diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 1d91409769e..962f47b7119 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -21,7 +21,7 @@ from xmodule.tests import DATA_DIR from xmodule.modulestore import Location, MONGO_MODULESTORE_TYPE from xmodule.modulestore.mongo import MongoModuleStore, MongoKeyValueStore from xmodule.modulestore.draft import DraftModuleStore -from xmodule.modulestore.locations import SlashSeparatedCourseKey, AssetLocation +from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from xmodule.modulestore.xml_exporter import export_to_xml from xmodule.modulestore.xml_importer import import_from_xml, perform_xlint from xmodule.contentstore.mongo import MongoContentStore diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py index 7cce7182497..eac4770b384 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py @@ -13,7 +13,7 @@ from xblock.fields import Scope from xmodule.course_module import CourseDescriptor from xmodule.modulestore.exceptions import (InsufficientSpecificationError, ItemNotFoundError, VersionConflictError, DuplicateItemError, DuplicateCourseError) -from xmodule.modulestore.locator import CourseLocator, BlockUsageLocator, VersionTree, LocalId +from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator, VersionTree, LocalId from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.x_module import XModuleMixin from xmodule.fields import Date, Timedelta diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py index 796a38223bd..769aa0c39de 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py @@ -5,7 +5,7 @@ import uuid import random from xmodule.modulestore.inheritance import InheritanceMixin -from xmodule.modulestore.locator import CourseLocator, BlockUsageLocator +from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore from xmodule.modulestore.mongo import MongoModuleStore, DraftMongoModuleStore from xmodule.modulestore.mongo.draft import DIRECT_ONLY_CATEGORIES diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py b/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py index e0facc92ee0..878620f55c8 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py @@ -12,7 +12,7 @@ from xmodule.modulestore import Location, XML_MODULESTORE_TYPE from .test_modulestore import check_path_to_location from xmodule.tests import DATA_DIR -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.tests.test_modulestore import check_has_course_method diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py b/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py index d39c81b43bc..37e4b9ef3f5 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py @@ -9,7 +9,7 @@ from xmodule.x_module import XModuleMixin from xmodule.modulestore import Location from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.modulestore.xml_importer import import_module -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.tests import DATA_DIR from uuid import uuid4 import unittest diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index 160097428f3..46dc9b7148c 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -20,8 +20,8 @@ from xmodule.mako_module import MakoDescriptorSystem from xmodule.x_module import XMLParsingSystem, policy_key from xmodule.modulestore.xml_exporter import DEFAULT_CONTENT_FIELDS from xmodule.tabs import CourseTabList -from xmodule.modulestore.keys import UsageKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import UsageKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xblock.field_data import DictFieldData from xblock.runtime import DictKeyValueStore, IdGenerator diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index d86221a7b6d..221852b73b5 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -7,7 +7,7 @@ import json from .xml import XMLModuleStore, ImportSystem, ParentTracker from xblock.runtime import KvsFieldData, DictKeyValueStore from xmodule.x_module import XModuleDescriptor -from xmodule.modulestore.keys import UsageKey +from opaque_keys.edx.keys import UsageKey from xblock.fields import Scope, Reference, ReferenceList, ReferenceValueDict from xmodule.contentstore.content import StaticContent from .inheritance import own_metadata diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py index c15f83b3051..9c5309d25b3 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py @@ -2,7 +2,7 @@ import logging from dogapi import dog_stats_api from .grading_service_module import GradingService -from xmodule.modulestore.keys import UsageKey +from opaque_keys.edx.keys import UsageKey log = logging.getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py index e967e8872c5..cbba120094a 100644 --- a/common/lib/xmodule/xmodule/tests/__init__.py +++ b/common/lib/xmodule/xmodule/tests/__init__.py @@ -20,7 +20,7 @@ from xblock.fields import ScopeIds from xmodule.x_module import ModuleSystem, XModuleDescriptor, XModuleMixin from xmodule.modulestore.inheritance import InheritanceMixin -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.mako_module import MakoDescriptorSystem from xmodule.error_module import ErrorDescriptor diff --git a/common/lib/xmodule/xmodule/tests/test_conditional.py b/common/lib/xmodule/xmodule/tests/test_conditional.py index d985ff7ef49..604c7c454ce 100644 --- a/common/lib/xmodule/xmodule/tests/test_conditional.py +++ b/common/lib/xmodule/xmodule/tests/test_conditional.py @@ -7,7 +7,7 @@ from mock import Mock, patch from xblock.field_data import DictFieldData from xblock.fields import ScopeIds from xmodule.error_module import NonStaffErrorDescriptor -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from xmodule.modulestore.xml import ImportSystem, XMLModuleStore, CourseLocationGenerator from xmodule.conditional_module import ConditionalDescriptor from xmodule.tests import DATA_DIR, get_test_system, get_test_descriptor_system diff --git a/common/lib/xmodule/xmodule/tests/test_content.py b/common/lib/xmodule/xmodule/tests/test_content.py index 4ce25269720..271d2114227 100644 --- a/common/lib/xmodule/xmodule/tests/test_content.py +++ b/common/lib/xmodule/xmodule/tests/test_content.py @@ -1,7 +1,7 @@ import unittest from xmodule.contentstore.content import StaticContent from xmodule.contentstore.content import ContentStore -from xmodule.modulestore.locations import SlashSeparatedCourseKey, AssetLocation +from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation class Content: diff --git a/common/lib/xmodule/xmodule/tests/test_course_module.py b/common/lib/xmodule/xmodule/tests/test_course_module.py index 51022d6b9a6..4aed11ece82 100644 --- a/common/lib/xmodule/xmodule/tests/test_course_module.py +++ b/common/lib/xmodule/xmodule/tests/test_course_module.py @@ -9,7 +9,7 @@ from xblock.runtime import KvsFieldData, DictKeyValueStore import xmodule.course_module from xmodule.modulestore.xml import ImportSystem, XMLModuleStore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.utils.timezone import UTC diff --git a/common/lib/xmodule/xmodule/tests/test_editing_module.py b/common/lib/xmodule/xmodule/tests/test_editing_module.py index 86e0568d0ad..01915830de5 100644 --- a/common/lib/xmodule/xmodule/tests/test_editing_module.py +++ b/common/lib/xmodule/xmodule/tests/test_editing_module.py @@ -5,7 +5,7 @@ import logging from mock import Mock from pkg_resources import resource_string -from xmodule.modulestore.locations import Location +from opaque_keys.edx.locations import Location from xmodule.editing_module import TabsEditingDescriptor from xblock.field_data import DictFieldData from xblock.fields import ScopeIds diff --git a/common/lib/xmodule/xmodule/tests/test_error_module.py b/common/lib/xmodule/xmodule/tests/test_error_module.py index 9050889e521..cb7cebb9358 100644 --- a/common/lib/xmodule/xmodule/tests/test_error_module.py +++ b/common/lib/xmodule/xmodule/tests/test_error_module.py @@ -5,7 +5,7 @@ import unittest from xmodule.tests import get_test_system from xmodule.error_module import ErrorDescriptor, ErrorModule, NonStaffErrorDescriptor from xmodule.modulestore.xml import CourseLocationGenerator -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from xmodule.x_module import XModuleDescriptor, XModule from mock import MagicMock, Mock, patch from xblock.runtime import Runtime, IdReader diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 7be88f18823..06ada7350f9 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -18,7 +18,7 @@ from xmodule.x_module import XModuleMixin from xmodule.fields import Date from xmodule.tests import DATA_DIR from xmodule.modulestore.inheritance import InheritanceMixin -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xblock.core import XBlock from xblock.fields import Scope, String, Integer diff --git a/common/lib/xmodule/xmodule/tests/test_import_static.py b/common/lib/xmodule/xmodule/tests/test_import_static.py index caea3ce6bd7..831d389dec7 100644 --- a/common/lib/xmodule/xmodule/tests/test_import_static.py +++ b/common/lib/xmodule/xmodule/tests/test_import_static.py @@ -4,7 +4,7 @@ Tests that check that we ignore the appropriate files when importing courses. import unittest from mock import Mock from xmodule.modulestore.xml_importer import import_static_content -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.tests import DATA_DIR diff --git a/common/lib/xmodule/xmodule/tests/test_peer_grading.py b/common/lib/xmodule/xmodule/tests/test_peer_grading.py index 75b494e55cc..5267bb53d88 100644 --- a/common/lib/xmodule/xmodule/tests/test_peer_grading.py +++ b/common/lib/xmodule/xmodule/tests/test_peer_grading.py @@ -7,7 +7,7 @@ from webob.multidict import MultiDict from xblock.field_data import DictFieldData from xblock.fields import ScopeIds -from xmodule.modulestore.locations import Location, SlashSeparatedCourseKey +from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey from xmodule.tests import get_test_system, get_test_descriptor_system from xmodule.tests.test_util_open_ended import DummyModulestore from xmodule.open_ended_grading_classes.peer_grading_service import MockPeerGradingService diff --git a/common/lib/xmodule/xmodule/tests/test_tabs.py b/common/lib/xmodule/xmodule/tests/test_tabs.py index ec88ad2efba..6d40d043170 100644 --- a/common/lib/xmodule/xmodule/tests/test_tabs.py +++ b/common/lib/xmodule/xmodule/tests/test_tabs.py @@ -2,7 +2,7 @@ from mock import MagicMock import xmodule.tabs as tabs import unittest -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class TabTestCase(unittest.TestCase): diff --git a/common/lib/xmodule/xmodule/tests/xml/__init__.py b/common/lib/xmodule/xmodule/tests/xml/__init__.py index 1d3ea3f904e..599fa498403 100644 --- a/common/lib/xmodule/xmodule/tests/xml/__init__.py +++ b/common/lib/xmodule/xmodule/tests/xml/__init__.py @@ -8,7 +8,7 @@ from unittest import TestCase from xmodule.x_module import XMLParsingSystem, policy_key from xmodule.mako_module import MakoDescriptorSystem from xmodule.modulestore.xml import create_block_from_xml, CourseLocationGenerator -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from xblock.runtime import KvsFieldData, DictKeyValueStore diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index c7b905b8607..5ba1df33cdb 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -18,12 +18,12 @@ from webob.multidict import MultiDict from xblock.core import XBlock from xblock.fields import Scope, Integer, Float, List, XBlockMixin, String, Dict from xblock.fragment import Fragment -from xblock.runtime import Runtime +from xblock.runtime import Runtime, IdReader from xmodule.fields import RelativeTime from xmodule.errortracker import exc_info_to_str from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.keys import OpaqueKeyReader, UsageKey +from opaque_keys.edx.keys import UsageKey from xmodule.exceptions import UndefinedContext from dogapi import dog_stats_api @@ -33,6 +33,33 @@ log = logging.getLogger(__name__) XMODULE_METRIC_NAME = 'edxapp.xmodule' +class OpaqueKeyReader(IdReader): + """ + IdReader for :class:`DefinitionKey` and :class:`UsageKey`s. + """ + def get_definition_id(self, usage_id): + """Retrieve the definition that a usage is derived from. + + Args: + usage_id: The id of the usage to query + + Returns: + The `definition_id` the usage is derived from + """ + return usage_id.definition_key + + def get_block_type(self, def_id): + """Retrieve the block_type of a particular definition + + Args: + def_id: The id of the definition to query + + Returns: + The `block_type` of the definition + """ + return def_id.block_type + + def dummy_track(_event_type, _event): pass diff --git a/docs/en_us/developers/source/modulestore.rst b/docs/en_us/developers/source/modulestore.rst index 596af8fe7b8..3fe9a50c168 100644 --- a/docs/en_us/developers/source/modulestore.rst +++ b/docs/en_us/developers/source/modulestore.rst @@ -54,28 +54,6 @@ and migrating data between modulestores. :show-inheritance: - -Content Keys -============ - -These packages provide the definition of the key types that are -used in the modulestores to address content, and definitions of -key types. - -.. automodule:: xmodule.modulestore.keys - :members: - :show-inheritance: - -.. automodule:: xmodule.modulestore.locations - :members: - :show-inheritance: - -.. automodule:: xmodule.modulestore.locator - :members: - :show-inheritance: - - - Xml Import/Export ================= diff --git a/lms/djangoapps/analytics/tests/test_basic.py b/lms/djangoapps/analytics/tests/test_basic.py index 8629aaf294f..5aae8d524f6 100644 --- a/lms/djangoapps/analytics/tests/test_basic.py +++ b/lms/djangoapps/analytics/tests/test_basic.py @@ -5,7 +5,7 @@ Tests for instructor.basic from django.test import TestCase from student.models import CourseEnrollment from student.tests.factories import UserFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from analytics.basic import enrolled_students_features, AVAILABLE_FEATURES, STUDENT_FEATURES, PROFILE_FEATURES diff --git a/lms/djangoapps/analytics/tests/test_distributions.py b/lms/djangoapps/analytics/tests/test_distributions.py index 1e2f588758f..2975186b29d 100644 --- a/lms/djangoapps/analytics/tests/test_distributions.py +++ b/lms/djangoapps/analytics/tests/test_distributions.py @@ -4,7 +4,7 @@ from django.test import TestCase from nose.tools import raises from student.models import CourseEnrollment from student.tests.factories import UserFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from analytics.distributions import profile_distribution, AVAILABLE_PROFILE_FEATURES diff --git a/lms/djangoapps/bulk_email/forms.py b/lms/djangoapps/bulk_email/forms.py index 43fda78fe96..cef116d6f4b 100644 --- a/lms/djangoapps/bulk_email/forms.py +++ b/lms/djangoapps/bulk_email/forms.py @@ -11,8 +11,8 @@ from bulk_email.models import CourseEmailTemplate, COURSE_EMAIL_MESSAGE_BODY_TAG from opaque_keys import InvalidKeyError from xmodule.modulestore import XML_MODULESTORE_TYPE from xmodule.modulestore.django import modulestore -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/bulk_email/tests/test_err_handling.py b/lms/djangoapps/bulk_email/tests/test_err_handling.py index d9942adf8a1..8dd68cf2527 100644 --- a/lms/djangoapps/bulk_email/tests/test_err_handling.py +++ b/lms/djangoapps/bulk_email/tests/test_err_handling.py @@ -19,7 +19,7 @@ from django.db import DatabaseError from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.tests.factories import UserFactory, AdminFactory, CourseEnrollmentFactory from bulk_email.models import CourseEmail, SEND_TO_ALL diff --git a/lms/djangoapps/bulk_email/tests/test_forms.py b/lms/djangoapps/bulk_email/tests/test_forms.py index 025c433e72c..4d75715ce8a 100644 --- a/lms/djangoapps/bulk_email/tests/test_forms.py +++ b/lms/djangoapps/bulk_email/tests/test_forms.py @@ -17,7 +17,7 @@ from mock import patch from bulk_email.models import CourseAuthorization from bulk_email.forms import CourseAuthorizationAdminForm -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) diff --git a/lms/djangoapps/bulk_email/tests/test_models.py b/lms/djangoapps/bulk_email/tests/test_models.py index c0a03f1ade0..09385cf820c 100644 --- a/lms/djangoapps/bulk_email/tests/test_models.py +++ b/lms/djangoapps/bulk_email/tests/test_models.py @@ -10,7 +10,7 @@ from student.tests.factories import UserFactory from mock import patch from bulk_email.models import CourseEmail, SEND_TO_STAFF, CourseEmailTemplate, CourseAuthorization -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class CourseEmailTest(TestCase): diff --git a/lms/djangoapps/bulk_email/tests/test_tasks.py b/lms/djangoapps/bulk_email/tests/test_tasks.py index 872781f14ca..dbc61fcec1b 100644 --- a/lms/djangoapps/bulk_email/tests/test_tasks.py +++ b/lms/djangoapps/bulk_email/tests/test_tasks.py @@ -35,7 +35,7 @@ from instructor_task.subtasks import update_subtask_status, SubtaskStatus from instructor_task.models import InstructorTask from instructor_task.tests.test_base import InstructorTaskCourseTestCase from instructor_task.tests.factories import InstructorTaskFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class TestTaskFailure(Exception): diff --git a/lms/djangoapps/certificates/management/commands/cert_whitelist.py b/lms/djangoapps/certificates/management/commands/cert_whitelist.py index a11d0c27d65..7604532dd0e 100644 --- a/lms/djangoapps/certificates/management/commands/cert_whitelist.py +++ b/lms/djangoapps/certificates/management/commands/cert_whitelist.py @@ -5,8 +5,8 @@ user/course from django.core.management.base import BaseCommand, CommandError from optparse import make_option from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from certificates.models import CertificateWhitelist from django.contrib.auth.models import User diff --git a/lms/djangoapps/certificates/management/commands/gen_cert_report.py b/lms/djangoapps/certificates/management/commands/gen_cert_report.py index 3c370697532..60524387eaf 100644 --- a/lms/djangoapps/certificates/management/commands/gen_cert_report.py +++ b/lms/djangoapps/certificates/management/commands/gen_cert_report.py @@ -9,8 +9,8 @@ from optparse import make_option from django.conf import settings from opaque_keys import InvalidKeyError from xmodule.course_module import CourseDescriptor -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.django import modulestore from django.db.models import Count diff --git a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py index 81c3e47f434..7718dc989b8 100644 --- a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py +++ b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py @@ -9,8 +9,8 @@ from django.contrib.auth.models import User from optparse import make_option from django.conf import settings from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.course_module import CourseDescriptor from xmodule.modulestore.django import modulestore from certificates.models import CertificateStatuses diff --git a/lms/djangoapps/certificates/views.py b/lms/djangoapps/certificates/views.py index ed5f1e67212..53073d1cf14 100644 --- a/lms/djangoapps/certificates/views.py +++ b/lms/djangoapps/certificates/views.py @@ -12,7 +12,7 @@ from certificates.models import certificate_status_for_student, CertificateStatu from certificates.queue import XQueueCertInterface from xmodule.course_module import CourseDescriptor from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey logger = logging.getLogger(__name__) diff --git a/lms/djangoapps/class_dashboard/views.py b/lms/djangoapps/class_dashboard/views.py index 3507f06d3ae..9ad9949a956 100644 --- a/lms/djangoapps/class_dashboard/views.py +++ b/lms/djangoapps/class_dashboard/views.py @@ -10,7 +10,7 @@ from django.http import HttpResponse from courseware.courses import get_course_with_access from courseware.access import has_access from class_dashboard import dashboard_data -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/course_wiki/tests/tests.py b/lms/djangoapps/course_wiki/tests/tests.py index 8252e49bbba..d12bdda138e 100644 --- a/lms/djangoapps/course_wiki/tests/tests.py +++ b/lms/djangoapps/course_wiki/tests/tests.py @@ -4,7 +4,7 @@ from django.test.utils import override_settings from courseware.tests.tests import LoginEnrollmentTestCase from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from mock import patch diff --git a/lms/djangoapps/course_wiki/views.py b/lms/djangoapps/course_wiki/views.py index 73d18bc3787..c7a97fd0775 100644 --- a/lms/djangoapps/course_wiki/views.py +++ b/lms/djangoapps/course_wiki/views.py @@ -16,7 +16,7 @@ from wiki.models import URLPath, Article from courseware.courses import get_course_by_id from course_wiki.utils import course_wiki_slug -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/courseware/access.py b/lms/djangoapps/courseware/access.py index 686e9968ed6..251e56c8eb1 100644 --- a/lms/djangoapps/courseware/access.py +++ b/lms/djangoapps/courseware/access.py @@ -23,7 +23,7 @@ from student.roles import ( GlobalStaff, CourseStaffRole, CourseInstructorRole, OrgStaffRole, OrgInstructorRole, CourseBetaTesterRole ) -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey DEBUG_ACCESS = False log = logging.getLogger(__name__) diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 0cf0af2f63b..fbc96a4dac4 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -9,7 +9,7 @@ from django.conf import settings from edxmako.shortcuts import render_to_string from xmodule.modulestore import XML_MODULESTORE_TYPE -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.django import modulestore from xmodule.contentstore.content import StaticContent from xmodule.modulestore.exceptions import ItemNotFoundError diff --git a/lms/djangoapps/courseware/features/common.py b/lms/djangoapps/courseware/features/common.py index 2ede62a84c3..736068ace3d 100644 --- a/lms/djangoapps/courseware/features/common.py +++ b/lms/djangoapps/courseware/features/common.py @@ -12,7 +12,7 @@ from django.core.urlresolvers import reverse from student.models import CourseEnrollment from xmodule.modulestore import Location from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.course_module import CourseDescriptor from courseware.courses import get_course_by_id from xmodule import seq_module, vertical_module diff --git a/lms/djangoapps/courseware/features/navigation.py b/lms/djangoapps/courseware/features/navigation.py index 10997b44ac5..7d05461fbc7 100644 --- a/lms/djangoapps/courseware/features/navigation.py +++ b/lms/djangoapps/courseware/features/navigation.py @@ -5,7 +5,7 @@ from lettuce import world, step from common import course_id, course_location from problems_setup import PROBLEM_DICT from nose.tools import assert_in -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @step(u'I am viewing a course with multiple sections') diff --git a/lms/djangoapps/courseware/management/commands/dump_course_structure.py b/lms/djangoapps/courseware/management/commands/dump_course_structure.py index 27e2658ad16..f32e8e10e1d 100644 --- a/lms/djangoapps/courseware/management/commands/dump_course_structure.py +++ b/lms/djangoapps/courseware/management/commands/dump_course_structure.py @@ -26,7 +26,7 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.inheritance import own_metadata, compute_inherited_metadata from xblock.fields import Scope from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey FILTER_LIST = ['xml_attributes', 'checklists'] INHERITED_FILTER_LIST = ['children', 'xml_attributes', 'checklists'] diff --git a/lms/djangoapps/courseware/management/commands/export_course.py b/lms/djangoapps/courseware/management/commands/export_course.py index 090143c9d98..f06c7890542 100644 --- a/lms/djangoapps/courseware/management/commands/export_course.py +++ b/lms/djangoapps/courseware/management/commands/export_course.py @@ -18,7 +18,7 @@ from django.core.management.base import BaseCommand, CommandError from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_exporter import export_to_xml from opaque_keys import InvalidKeyError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py b/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py index 4d33b88f264..e6151041789 100644 --- a/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py +++ b/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py @@ -22,7 +22,7 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.xml_importer import import_from_xml -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey DATA_DIR = 'common/test/data/' diff --git a/lms/djangoapps/courseware/model_data.py b/lms/djangoapps/courseware/model_data.py index 0a459e52cb4..ea825131395 100644 --- a/lms/djangoapps/courseware/model_data.py +++ b/lms/djangoapps/courseware/model_data.py @@ -12,7 +12,7 @@ from .models import ( XModuleStudentInfoField ) import logging -from xmodule.modulestore.locations import SlashSeparatedCourseKey, Location +from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from django.db import DatabaseError from django.contrib.auth.models import User diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 0a074b23139..3976a00fece 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -34,7 +34,7 @@ from xblock.exceptions import NoSuchHandlerError from xblock.django.request import django_to_webob_request, webob_to_django_response from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor from xmodule.exceptions import NotFoundError, ProcessingError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.django import modulestore, ModuleI18nService from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.util.duedate import get_extended_due_date diff --git a/lms/djangoapps/courseware/tests/factories.py b/lms/djangoapps/courseware/tests/factories.py index f427aa1cf66..073d0085c86 100644 --- a/lms/djangoapps/courseware/tests/factories.py +++ b/lms/djangoapps/courseware/tests/factories.py @@ -22,7 +22,7 @@ from student.roles import ( OrgInstructorRole, ) -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey # TODO fix this (course_id and location are invalid names as constants, and course_id should really be COURSE_KEY) diff --git a/lms/djangoapps/courseware/tests/test_about.py b/lms/djangoapps/courseware/tests/test_about.py index 165e03cee18..6b616ac3334 100644 --- a/lms/djangoapps/courseware/tests/test_about.py +++ b/lms/djangoapps/courseware/tests/test_about.py @@ -9,7 +9,7 @@ from .helpers import LoginEnrollmentTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) diff --git a/lms/djangoapps/courseware/tests/test_access.py b/lms/djangoapps/courseware/tests/test_access.py index dc999b51c34..fdee1013478 100644 --- a/lms/djangoapps/courseware/tests/test_access.py +++ b/lms/djangoapps/courseware/tests/test_access.py @@ -10,7 +10,7 @@ from courseware.tests.factories import UserFactory, StaffFactory, InstructorFact from student.tests.factories import AnonymousUserFactory, CourseEnrollmentAllowedFactory from courseware.tests.tests import TEST_DATA_MIXED_MODULESTORE import pytz -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey # pylint: disable=protected-access diff --git a/lms/djangoapps/courseware/tests/test_courses.py b/lms/djangoapps/courseware/tests/test_courses.py index bcc6c4c8b57..0e5d288a316 100644 --- a/lms/djangoapps/courseware/tests/test_courses.py +++ b/lms/djangoapps/courseware/tests/test_courses.py @@ -18,7 +18,7 @@ from courseware.courses import ( ) from courseware.tests.helpers import get_request_for_user from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE, TEST_DATA_MIXED_MODULESTORE -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey CMS_BASE_TEST = 'testcms' diff --git a/lms/djangoapps/courseware/tests/test_draft_modulestore.py b/lms/djangoapps/courseware/tests/test_draft_modulestore.py index 3d5f9f471c1..67ddcc73418 100644 --- a/lms/djangoapps/courseware/tests/test_draft_modulestore.py +++ b/lms/djangoapps/courseware/tests/test_draft_modulestore.py @@ -2,7 +2,7 @@ from django.test import TestCase from django.test.utils import override_settings from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from modulestore_config import TEST_DATA_DRAFT_MONGO_MODULESTORE diff --git a/lms/djangoapps/courseware/tests/test_grades.py b/lms/djangoapps/courseware/tests/test_grades.py index 805c5d2e354..9518f76c660 100644 --- a/lms/djangoapps/courseware/tests/test_grades.py +++ b/lms/djangoapps/courseware/tests/test_grades.py @@ -9,7 +9,7 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from student.tests.factories import UserFactory from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.grades import grade, iterate_grades_for diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py index 9fb94331681..f26f2d00e94 100644 --- a/lms/djangoapps/courseware/tests/test_masquerade.py +++ b/lms/djangoapps/courseware/tests/test_masquerade.py @@ -19,7 +19,7 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.django import modulestore, clear_existing_modulestores from lms.lib.xblock.runtime import quote_slashes -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 44e36c46c33..548a1df1529 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -23,7 +23,7 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory from xmodule.x_module import XModuleDescriptor -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware import module_render as render from courseware.courses import get_course_with_access, course_image_url, get_course_info_section diff --git a/lms/djangoapps/courseware/tests/test_tabs.py b/lms/djangoapps/courseware/tests/test_tabs.py index 0192e0bec53..f215936072e 100644 --- a/lms/djangoapps/courseware/tests/test_tabs.py +++ b/lms/djangoapps/courseware/tests/test_tabs.py @@ -15,7 +15,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from courseware.tests.helpers import get_request_for_user, LoginEnrollmentTestCase from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) diff --git a/lms/djangoapps/courseware/tests/test_video_handlers.py b/lms/djangoapps/courseware/tests/test_video_handlers.py index 4e332c91a81..06a2373c143 100644 --- a/lms/djangoapps/courseware/tests/test_video_handlers.py +++ b/lms/djangoapps/courseware/tests/test_video_handlers.py @@ -22,7 +22,7 @@ from xmodule.video_module.transcripts_utils import ( TranscriptException, TranscriptsGenerationException, ) -from xmodule.modulestore.locations import AssetLocation +from opaque_keys.edx.locations import AssetLocation SRT_content = textwrap.dedent(""" 0 diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 9e1f69e2fd1..b2b7491e655 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -14,7 +14,7 @@ from xmodule.video_module import create_youtube_string from xmodule.tests import get_test_descriptor_system from xmodule.modulestore import Location from xmodule.video_module import VideoDescriptor -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from . import BaseTestXmodule from .test_video_xml import SOURCE_XML diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 213c3d1b318..64691ce29cc 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -25,7 +25,7 @@ from xmodule.modulestore import Location from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.tests.factories import UserFactory import courseware.views as views diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index 2132a01c8e1..e55c6ad98eb 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -11,7 +11,7 @@ from textwrap import dedent from xmodule.error_module import ErrorDescriptor from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index c7df0ca3fca..3e02a46e664 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -46,7 +46,7 @@ import shoppingcart from opaque_keys import InvalidKeyError from microsite_configuration import microsite -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger("edx.courseware") diff --git a/lms/djangoapps/dashboard/git_import.py b/lms/djangoapps/dashboard/git_import.py index 9b92cdba403..9f0788d011d 100644 --- a/lms/djangoapps/dashboard/git_import.py +++ b/lms/djangoapps/dashboard/git_import.py @@ -18,8 +18,8 @@ import mongoengine from dashboard.models import CourseImportLog from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py b/lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py index a1e76fad2b1..f3fb82b5da8 100644 --- a/lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py +++ b/lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py @@ -17,12 +17,11 @@ from django.test.utils import override_settings from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.store_utilities import delete_course from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase import dashboard.git_import as git_import from dashboard.git_import import GitImportError -from xmodule.modulestore.locations import SlashSeparatedCourseKey TEST_MONGODB_LOG = { 'host': 'localhost', @@ -89,7 +88,6 @@ class TestGitAddCourse(ModuleStoreTestCase): self.GIT_REPO_DIR / 'edx4edx_lite', self.TEST_BRANCH) - def test_add_repo(self): """ Various exit path tests for test_add_repo diff --git a/lms/djangoapps/dashboard/sysadmin.py b/lms/djangoapps/dashboard/sysadmin.py index 3d7a5ede267..d0c9aed2c62 100644 --- a/lms/djangoapps/dashboard/sysadmin.py +++ b/lms/djangoapps/dashboard/sysadmin.py @@ -43,7 +43,7 @@ from xmodule.modulestore import XML_MODULESTORE_TYPE from xmodule.modulestore.django import modulestore from xmodule.modulestore.store_utilities import delete_course from xmodule.modulestore.xml import XMLModuleStore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/dashboard/tests/test_sysadmin.py b/lms/djangoapps/dashboard/tests/test_sysadmin.py index 8b77aa5d20a..e5040727b94 100644 --- a/lms/djangoapps/dashboard/tests/test_sysadmin.py +++ b/lms/djangoapps/dashboard/tests/test_sysadmin.py @@ -27,7 +27,7 @@ from student.tests.factories import UserFactory from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.xml import XMLModuleStore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey TEST_MONGODB_LOG = { diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 538d62dff58..6f8939a4bc2 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -24,8 +24,8 @@ from django_comment_client.utils import JsonResponse, JsonError, extract, add_co from django_comment_client.permissions import check_permissions_by_view, cached_has_permission from courseware.access import has_access -from xmodule.modulestore.locations import SlashSeparatedCourseKey -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 957629e3e0a..fa89fa35c2e 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -21,7 +21,7 @@ from django_comment_client.utils import (merge_dict, extract, strip_none, add_co import django_comment_client.utils as utils import lms.lib.comment_client as cc -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey THREADS_PER_PAGE = 20 INLINE_THREADS_PER_PAGE = 20 diff --git a/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py b/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py index 7376429d76a..80419db8f61 100644 --- a/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py +++ b/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py @@ -1,7 +1,7 @@ from django.core.management.base import BaseCommand, CommandError from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.courses import get_course diff --git a/lms/djangoapps/django_comment_client/management/commands/seed_permissions_roles.py b/lms/djangoapps/django_comment_client/management/commands/seed_permissions_roles.py index 3650aab05c4..6e4fabb6b62 100644 --- a/lms/djangoapps/django_comment_client/management/commands/seed_permissions_roles.py +++ b/lms/djangoapps/django_comment_client/management/commands/seed_permissions_roles.py @@ -3,7 +3,7 @@ Management command to seed default permissions and roles. """ from django.core.management.base import BaseCommand, CommandError from django_comment_common.utils import seed_permissions_roles -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/lms/djangoapps/django_comment_client/permissions.py b/lms/djangoapps/django_comment_client/permissions.py index f43bd88c78b..1d2f5f39940 100644 --- a/lms/djangoapps/django_comment_client/permissions.py +++ b/lms/djangoapps/django_comment_client/permissions.py @@ -5,7 +5,7 @@ Module for checking permissions with the comment_client backend import logging from types import NoneType from django.core import cache -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey CACHE = cache.get_cache('default') CACHE_LIFESPAN = 60 diff --git a/lms/djangoapps/django_comment_client/tests/test_models.py b/lms/djangoapps/django_comment_client/tests/test_models.py index 376be6d3ede..e82cb44b8f7 100644 --- a/lms/djangoapps/django_comment_client/tests/test_models.py +++ b/lms/djangoapps/django_comment_client/tests/test_models.py @@ -1,7 +1,7 @@ import django_comment_common.models as models from django.test import TestCase -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class RoleClassTestCase(TestCase): diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 1e5d3e9c9d1..9d19eb8e1a3 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -16,7 +16,7 @@ import pystache_custom as pystache from xmodule.modulestore.django import modulestore from django.utils.timezone import UTC -from xmodule.modulestore.locations import i4xEncoder, SlashSeparatedCourseKey +from opaque_keys.edx.locations import i4xEncoder, SlashSeparatedCourseKey import json log = logging.getLogger(__name__) diff --git a/lms/djangoapps/foldit/tests.py b/lms/djangoapps/foldit/tests.py index a5992ae6a48..60a8c661b1a 100644 --- a/lms/djangoapps/foldit/tests.py +++ b/lms/djangoapps/foldit/tests.py @@ -13,7 +13,7 @@ from student.tests.factories import UserFactory from datetime import datetime, timedelta from pytz import UTC -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) diff --git a/lms/djangoapps/instructor/hint_manager.py b/lms/djangoapps/instructor/hint_manager.py index 30604da34be..1ec82ef6f32 100644 --- a/lms/djangoapps/instructor/hint_manager.py +++ b/lms/djangoapps/instructor/hint_manager.py @@ -20,7 +20,7 @@ from courseware.models import XModuleUserStateSummaryField import courseware.module_render as module_render import courseware.model_data as model_data from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.exceptions import ItemNotFoundError diff --git a/lms/djangoapps/instructor/management/commands/compute_grades.py b/lms/djangoapps/instructor/management/commands/compute_grades.py index 8479474872c..6d0d45d548c 100644 --- a/lms/djangoapps/instructor/management/commands/compute_grades.py +++ b/lms/djangoapps/instructor/management/commands/compute_grades.py @@ -7,8 +7,8 @@ from instructor.offline_gradecalc import offline_grade_calculation from courseware.courses import get_course_by_id from xmodule.modulestore.django import modulestore from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.core.management.base import BaseCommand diff --git a/lms/djangoapps/instructor/management/commands/dump_grades.py b/lms/djangoapps/instructor/management/commands/dump_grades.py index a2a68fb21a5..1fd7661eb93 100644 --- a/lms/djangoapps/instructor/management/commands/dump_grades.py +++ b/lms/djangoapps/instructor/management/commands/dump_grades.py @@ -8,8 +8,8 @@ import csv from instructor.views.legacy import get_student_grade_summary_data from courseware.courses import get_course_by_id from opaque_keys import InvalidKeyError -from xmodule.modulestore.keys import CourseKey -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.django import modulestore from django.core.management.base import BaseCommand diff --git a/lms/djangoapps/instructor/management/commands/openended_post.py b/lms/djangoapps/instructor/management/commands/openended_post.py index b3e6251cca8..8f7992c3588 100644 --- a/lms/djangoapps/instructor/management/commands/openended_post.py +++ b/lms/djangoapps/instructor/management/commands/openended_post.py @@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand from optparse import make_option from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.open_ended_grading_classes.openendedchild import OpenEndedChild from xmodule.open_ended_grading_classes.open_ended_module import OpenEndedModule diff --git a/lms/djangoapps/instructor/management/commands/openended_stats.py b/lms/djangoapps/instructor/management/commands/openended_stats.py index fef4fe73e48..3588d90010a 100644 --- a/lms/djangoapps/instructor/management/commands/openended_stats.py +++ b/lms/djangoapps/instructor/management/commands/openended_stats.py @@ -9,7 +9,7 @@ from optparse import make_option from xmodule.modulestore import Location from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.open_ended_grading_classes.openendedchild import OpenEndedChild from courseware.courses import get_course diff --git a/lms/djangoapps/instructor/management/tests/test_openended_commands.py b/lms/djangoapps/instructor/management/tests/test_openended_commands.py index 592f291248f..e996f05bbab 100644 --- a/lms/djangoapps/instructor/management/tests/test_openended_commands.py +++ b/lms/djangoapps/instructor/management/tests/test_openended_commands.py @@ -24,7 +24,7 @@ from instructor.management.commands.openended_post import post_submission_for_st from instructor.management.commands.openended_stats import calculate_task_statistics from instructor.utils import get_module_for_student -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index b5451c5bdc1..d3d9ca704ae 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -40,7 +40,7 @@ from instructor.access import allow_access import instructor.views.api from instructor.views.api import _split_input_list, common_exceptions_400 from instructor_task.api_helper import AlreadyRunningError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from .test_tools import msk_from_problem_urlname, get_extended_due diff --git a/lms/djangoapps/instructor/tests/test_email.py b/lms/djangoapps/instructor/tests/test_email.py index 56910767081..f19e062ac03 100644 --- a/lms/djangoapps/instructor/tests/test_email.py +++ b/lms/djangoapps/instructor/tests/test_email.py @@ -18,7 +18,7 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from mock import patch from bulk_email.models import CourseAuthorization -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) diff --git a/lms/djangoapps/instructor/tests/test_enrollment.py b/lms/djangoapps/instructor/tests/test_enrollment.py index ddc0c69329f..d25ca6a1712 100644 --- a/lms/djangoapps/instructor/tests/test_enrollment.py +++ b/lms/djangoapps/instructor/tests/test_enrollment.py @@ -22,7 +22,7 @@ from instructor.enrollment import ( send_beta_role_email, unenroll_email ) -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from submissions import api as sub_api from student.models import anonymous_id_for_user diff --git a/lms/djangoapps/instructor/tests/test_legacy_anon_csv.py b/lms/djangoapps/instructor/tests/test_legacy_anon_csv.py index 42fc923f51f..ee157d27fde 100644 --- a/lms/djangoapps/instructor/tests/test_legacy_anon_csv.py +++ b/lms/djangoapps/instructor/tests/test_legacy_anon_csv.py @@ -21,7 +21,7 @@ import instructor.views.legacy from student.roles import CourseStaffRole from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.django import modulestore, clear_existing_modulestores -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from mock import Mock, patch diff --git a/lms/djangoapps/instructor/tests/test_legacy_download_csv.py b/lms/djangoapps/instructor/tests/test_legacy_download_csv.py index 21068835a19..2e13df8f246 100644 --- a/lms/djangoapps/instructor/tests/test_legacy_download_csv.py +++ b/lms/djangoapps/instructor/tests/test_legacy_download_csv.py @@ -20,7 +20,7 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from student.roles import CourseStaffRole from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.django import modulestore, clear_existing_modulestores -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) diff --git a/lms/djangoapps/instructor/tests/test_legacy_forum_admin.py b/lms/djangoapps/instructor/tests/test_legacy_forum_admin.py index a236742eeb5..4dd0994ffff 100644 --- a/lms/djangoapps/instructor/tests/test_legacy_forum_admin.py +++ b/lms/djangoapps/instructor/tests/test_legacy_forum_admin.py @@ -17,7 +17,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from student.roles import CourseStaffRole from xmodule.modulestore.django import modulestore, clear_existing_modulestores -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/lms/djangoapps/instructor/tests/test_tools.py b/lms/djangoapps/instructor/tests/test_tools.py index 3c5ce3e16f7..b7c539eb0b0 100644 --- a/lms/djangoapps/instructor/tests/test_tools.py +++ b/lms/djangoapps/instructor/tests/test_tools.py @@ -17,7 +17,7 @@ from student.tests.factories import UserFactory from xmodule.fields import Date from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory -from xmodule.modulestore.keys import CourseKey +from opaque_keys.edx.keys import CourseKey from ..views import tools diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index f4822fcb525..e9832cf2d50 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -70,7 +70,7 @@ from .tools import ( bulk_email_is_enabled_for_course, ) from xmodule.modulestore import Location -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys import InvalidKeyError log = logging.getLogger(__name__) diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 4fa8a282e46..85e560ed62f 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -28,7 +28,7 @@ from bulk_email.models import CourseAuthorization from class_dashboard.dashboard_data import get_section_display_name, get_array_section_has_problem from .tools import get_units_with_due_date, title_or_url, bulk_email_is_enabled_for_course -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey @ensure_csrf_cookie diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 36e51a4e1ec..bd8d64471fa 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -30,7 +30,7 @@ from xmodule_modifiers import wrap_xblock import xmodule.graders as xmgraders from xmodule.modulestore import XML_MODULESTORE_TYPE from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.html_module import HtmlDescriptor from opaque_keys import InvalidKeyError @@ -79,7 +79,7 @@ from xblock.fields import ScopeIds from django.utils.translation import ugettext as _ from microsite_configuration import microsite -from xmodule.modulestore.locations import i4xEncoder +from opaque_keys.edx.locations import i4xEncoder log = logging.getLogger(__name__) diff --git a/lms/djangoapps/instructor_task/api_helper.py b/lms/djangoapps/instructor_task/api_helper.py index 6c9603bf381..b6f2797834a 100644 --- a/lms/djangoapps/instructor_task/api_helper.py +++ b/lms/djangoapps/instructor_task/api_helper.py @@ -14,7 +14,7 @@ from celery.states import READY_STATES, SUCCESS, FAILURE, REVOKED from courseware.module_render import get_xqueue_callback_url_prefix from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import Location +from opaque_keys.edx.locations import Location from instructor_task.models import InstructorTask, PROGRESS diff --git a/lms/djangoapps/instructor_task/tests/factories.py b/lms/djangoapps/instructor_task/tests/factories.py index e1d37908f1c..4f67b52ef6e 100644 --- a/lms/djangoapps/instructor_task/tests/factories.py +++ b/lms/djangoapps/instructor_task/tests/factories.py @@ -5,7 +5,7 @@ from factory.django import DjangoModelFactory from student.tests.factories import UserFactory as StudentUserFactory from instructor_task.models import InstructorTask from celery.states import PENDING -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class InstructorTaskFactory(DjangoModelFactory): diff --git a/lms/djangoapps/instructor_task/tests/test_base.py b/lms/djangoapps/instructor_task/tests/test_base.py index fb3b159ede0..c1ab66ceb87 100644 --- a/lms/djangoapps/instructor_task/tests/test_base.py +++ b/lms/djangoapps/instructor_task/tests/test_base.py @@ -16,7 +16,7 @@ from capa.tests.response_xml_factory import OptionResponseXMLFactory from xmodule.modulestore.django import editable_modulestore from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.locations import Location, SlashSeparatedCourseKey +from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey from student.tests.factories import CourseEnrollmentFactory, UserFactory from courseware.model_data import StudentModule diff --git a/lms/djangoapps/instructor_task/tests/test_tasks.py b/lms/djangoapps/instructor_task/tests/test_tasks.py index ef4a5b9c207..d6e2ce8cac8 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks.py @@ -13,7 +13,7 @@ from mock import Mock, MagicMock, patch from celery.states import SUCCESS, FAILURE from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.locations import i4xEncoder +from opaque_keys.edx.locations import i4xEncoder from courseware.models import StudentModule from courseware.tests.factories import StudentModuleFactory diff --git a/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py b/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py index 063ae02c473..9774427b9c1 100644 --- a/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py +++ b/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py @@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand, CommandError from xmodule.modulestore.django import modulestore from licenses.models import CourseSoftware, UserLicense -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/lms/djangoapps/licenses/management/commands/import_serial_numbers.py b/lms/djangoapps/licenses/management/commands/import_serial_numbers.py index 50c61509c49..ed9ce03ca2d 100644 --- a/lms/djangoapps/licenses/management/commands/import_serial_numbers.py +++ b/lms/djangoapps/licenses/management/commands/import_serial_numbers.py @@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand, CommandError from xmodule.modulestore.django import modulestore from licenses.models import CourseSoftware, UserLicense -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey class Command(BaseCommand): diff --git a/lms/djangoapps/licenses/views.py b/lms/djangoapps/licenses/views.py index a47499e6369..839c145df58 100644 --- a/lms/djangoapps/licenses/views.py +++ b/lms/djangoapps/licenses/views.py @@ -6,7 +6,7 @@ from collections import namedtuple, defaultdict from edxmako.shortcuts import render_to_string -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User diff --git a/lms/djangoapps/notes/api.py b/lms/djangoapps/notes/api.py index d782d7543ce..657e97f92ea 100644 --- a/lms/djangoapps/notes/api.py +++ b/lms/djangoapps/notes/api.py @@ -1,4 +1,4 @@ -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.contrib.auth.decorators import login_required from django.http import HttpResponse, Http404 from django.core.exceptions import ValidationError diff --git a/lms/djangoapps/notes/tests.py b/lms/djangoapps/notes/tests.py index ea7aa4b37f6..3484fd66eb2 100644 --- a/lms/djangoapps/notes/tests.py +++ b/lms/djangoapps/notes/tests.py @@ -2,7 +2,7 @@ Unit tests for the notes app. """ -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.test import TestCase from django.test.client import Client from django.core.urlresolvers import reverse diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index 4fb8a116616..946bbcc1070 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -9,7 +9,7 @@ from django.conf import settings from django.http import HttpResponse, Http404 from django.utils.translation import ugettext as _ -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.open_ended_grading_classes.grading_service_module import GradingService, GradingServiceError from xmodule.modulestore.django import ModuleI18nService diff --git a/lms/djangoapps/open_ended_grading/tests.py b/lms/djangoapps/open_ended_grading/tests.py index 43ba2aeab67..9403ca93e1e 100644 --- a/lms/djangoapps/open_ended_grading/tests.py +++ b/lms/djangoapps/open_ended_grading/tests.py @@ -18,7 +18,7 @@ from xblock.fields import ScopeIds from xmodule import peer_grading_module from xmodule.error_module import ErrorDescriptor from xmodule.modulestore.django import modulestore -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.open_ended_grading_classes import peer_grading_service, controller_query_service from xmodule.tests import test_util_open_ended diff --git a/lms/djangoapps/open_ended_grading/views.py b/lms/djangoapps/open_ended_grading/views.py index 26c6bbe0217..32e2a9f3242 100644 --- a/lms/djangoapps/open_ended_grading/views.py +++ b/lms/djangoapps/open_ended_grading/views.py @@ -14,7 +14,7 @@ import open_ended_notifications from xmodule.modulestore.django import modulestore from xmodule.modulestore import search -from xmodule.modulestore import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.exceptions import NoPathToItem from django.http import HttpResponse, Http404, HttpResponseRedirect diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index 26c9ad9d1dc..5f4a9110715 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -13,7 +13,7 @@ from django.test.utils import override_settings from django.contrib.auth.models import AnonymousUser from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from shoppingcart.models import (Order, OrderItem, CertificateItem, InvalidCartItem, PaidCourseRegistration, OrderItemSubclassPK) diff --git a/lms/djangoapps/shoppingcart/views.py b/lms/djangoapps/shoppingcart/views.py index c5bf21bac17..a01648e0cb0 100644 --- a/lms/djangoapps/shoppingcart/views.py +++ b/lms/djangoapps/shoppingcart/views.py @@ -11,7 +11,7 @@ from django.core.urlresolvers import reverse from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.decorators import login_required from edxmako.shortcuts import render_to_response -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from shoppingcart.reports import RefundReport, ItemizedPurchaseReport, UniversityRevenueShareReport, CertificateStatusReport from student.models import CourseEnrollment from .exceptions import ItemAlreadyInCartException, AlreadyEnrolledInCourseException, CourseDoesNotExistException, ReportTypeDoesNotExistException diff --git a/lms/djangoapps/staticbook/views.py b/lms/djangoapps/staticbook/views.py index 3df692d7de4..518fb589022 100644 --- a/lms/djangoapps/staticbook/views.py +++ b/lms/djangoapps/staticbook/views.py @@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required from django.http import Http404 from edxmako.shortcuts import render_to_response -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.access import has_access from courseware.courses import get_course_with_access from notes.utils import notes_enabled_for_course diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index 8b7a0d9b274..048b089dbf2 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -2,7 +2,7 @@ from datetime import timedelta, datetime import json from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from nose.tools import assert_is_none, assert_equals, assert_raises, assert_true, assert_false from mock import patch import pytz diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index 0d68f041640..4359d9d943b 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -25,7 +25,7 @@ from django.core.urlresolvers import reverse from django.core.exceptions import ObjectDoesNotExist from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from student.tests.factories import UserFactory from student.models import CourseEnrollment diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index e5b08ad3182..9b47e925d55 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -34,7 +34,7 @@ from verify_student.models import ( from reverification.models import MidcourseReverificationWindow import ssencrypt from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from .exceptions import WindowExpiredException log = logging.getLogger(__name__) diff --git a/lms/lib/xblock/test/test_runtime.py b/lms/lib/xblock/test/test_runtime.py index a18677b8bcc..dd6f9200fda 100644 --- a/lms/lib/xblock/test/test_runtime.py +++ b/lms/lib/xblock/test/test_runtime.py @@ -8,7 +8,7 @@ from ddt import ddt, data from mock import Mock from unittest import TestCase from urlparse import urlparse -from xmodule.modulestore.locations import SlashSeparatedCourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey from lms.lib.xblock.runtime import quote_slashes, unquote_slashes, LmsModuleSystem TEST_STRINGS = [ diff --git a/requirements/edx/github.txt b/requirements/edx/github.txt index e3110346d67..bfb4503af35 100644 --- a/requirements/edx/github.txt +++ b/requirements/edx/github.txt @@ -27,7 +27,7 @@ -e git+https://github.com/edx-solutions/django-splash.git@9965a53c269666a30bb4e2b3f6037c138aef2a55#egg=django-splash -e git+https://github.com/edx/acid-block.git@459aff7b63db8f2c5decd1755706c1a64fb4ebb1#egg=acid-xblock -e git+https://github.com/edx/edx-ora2.git@release-2014-05-23T16.59#egg=edx-ora2 --e git+https://github.com/edx/opaque-keys.git@1f5ab1abd8273559795b0460e74658e7cd8adc8d#egg=opaque-keys +-e git+https://github.com/edx/opaque-keys.git@91b7ec93cfb57c6739332e85805296626b4fb1db#egg=opaque-keys git+https://github.com/edx/ease.git@6eee938f98777367b414217c09a8dce05efc2d7f#egg=ease # Prototype XBlocks for limited roll-outs and user testing. These are not for general use. -- GitLab