diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index b93de39bd2..9016bca2c9 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -95,7 +95,7 @@ def _load_mixed_class(category): """ Load an XBlock by category name, and apply all defined mixins """ - component_class = XBlock.load_class(category, select=settings.XBLOCK_SELECT_FUNCTION) + component_class = XBlock.load_class(category) mixologist = Mixologist(settings.XBLOCK_MIXINS) return mixologist.mix(component_class) diff --git a/cms/djangoapps/contentstore/views/helpers.py b/cms/djangoapps/contentstore/views/helpers.py index 424fe76475..9c2fd8b732 100644 --- a/cms/djangoapps/contentstore/views/helpers.py +++ b/cms/djangoapps/contentstore/views/helpers.py @@ -5,7 +5,6 @@ Helper methods for Studio views. import urllib from uuid import uuid4 -from django.conf import settings from django.http import HttpResponse from django.utils.translation import gettext as _ from opaque_keys.edx.keys import UsageKey @@ -134,7 +133,7 @@ def xblock_type_display_name(xblock, default_display_name=None): return _('Subsection') elif category == 'vertical': return _('Unit') - component_class = XBlock.load_class(category, select=settings.XBLOCK_SELECT_FUNCTION) + component_class = XBlock.load_class(category) if hasattr(component_class, 'display_name') and component_class.display_name.default: return _(component_class.display_name.default) # lint-amnesty, pylint: disable=translation-of-non-string else: diff --git a/cms/envs/common.py b/cms/envs/common.py index 27e16e5c43..54c16cf930 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -926,7 +926,6 @@ P3P_HEADER = 'CP="Open EdX does not have a P3P policy."' # Import after sys.path fixup from xmodule.modulestore.inheritance import InheritanceMixin -from xmodule.modulestore import prefer_xmodules from xmodule.x_module import XModuleMixin # These are the Mixins that should be added to every XBlock. @@ -941,8 +940,6 @@ XBLOCK_MIXINS = ( ) XBLOCK_EXTRA_MIXINS = () -XBLOCK_SELECT_FUNCTION = prefer_xmodules - # Paths to wrapper methods which should be applied to every XBlock's FieldData. XBLOCK_FIELD_DATA_WRAPPERS = () diff --git a/lms/djangoapps/debug/management/__init__.py b/lms/djangoapps/debug/management/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lms/djangoapps/debug/management/commands/__init__.py b/lms/djangoapps/debug/management/commands/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lms/djangoapps/debug/management/commands/dump_xml_courses.py b/lms/djangoapps/debug/management/commands/dump_xml_courses.py deleted file mode 100644 index 3c92c9258a..0000000000 --- a/lms/djangoapps/debug/management/commands/dump_xml_courses.py +++ /dev/null @@ -1,57 +0,0 @@ -""" -Export all xml courses in a diffable format. - -This command loads all of the xml courses in the configured DATA_DIR. -For each of the courses, it loops through all of the modules, and dumps -each as a separate output file containing the json representation -of each of its fields (including those fields that are set as default values). -""" -import json - -from django.conf import settings -from django.core.management.base import BaseCommand, CommandError -from path import Path as path - -from xmodule.modulestore.xml import XMLModuleStore - - -class Command(BaseCommand): - """ - Django management command to export diffable representations of all xml courses - """ - help = '''Dump the in-memory representation of all xml courses in a diff-able format''' - args = '' - - def handle(self, *args, **options): - if len(args) != 1: - raise CommandError(f'Must called with arguments: {self.args}') - - xml_module_store = XMLModuleStore( - data_dir=settings.DATA_DIR, - default_class='xmodule.hidden_module.HiddenDescriptor', - load_error_modules=True, - xblock_mixins=settings.XBLOCK_MIXINS, - xblock_select=settings.XBLOCK_SELECT_FUNCTION, - ) - - export_dir = path(args[0]) - - for course_id, course_modules in xml_module_store.modules.items(): - course_path = course_id.replace('/', '_') - for location, descriptor in course_modules.items(): - location_path = str(location).replace('/', '_') - data = {} - for field_name, field in descriptor.fields.items(): - try: - data[field_name] = field.read_json(descriptor) - except Exception as exc: # pylint: disable=broad-except - data[field_name] = { - '$type': str(type(exc)), - '$value': descriptor._field_data.get(descriptor, field_name) # pylint: disable=protected-access - } - - outdir = export_dir / course_path - outdir.makedirs_p() - with open(outdir / location_path + '.json', 'w') as outfile: - json.dump(data, outfile, sort_keys=True, indent=4) - print('', file=outfile) diff --git a/lms/envs/common.py b/lms/envs/common.py index c7d0780afb..0d48109753 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1519,7 +1519,6 @@ COURSE_LISTINGS = {} # Import after sys.path fixup from xmodule.modulestore.edit_info import EditInfoMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position from xmodule.modulestore.inheritance import InheritanceMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position -from xmodule.modulestore import prefer_xmodules # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position from xmodule.x_module import XModuleMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position # These are the Mixins that should be added to every XBlock. @@ -1528,14 +1527,6 @@ from xmodule.x_module import XModuleMixin # lint-amnesty, pylint: disable=wrong XBLOCK_MIXINS = (LmsBlockMixin, InheritanceMixin, XModuleMixin, EditInfoMixin) XBLOCK_EXTRA_MIXINS = () -# .. setting_name: XBLOCK_SELECT_FUNCTION -# .. setting_default: prefer_xmodules -# .. setting_description: Function used to select an XBlock from the python package EntryPoints. -# Some alternatives are `prefer_xmodules` and `default_select`. The `prefer_modules` function -# will choose the first "xmodule" if there is one, otherwise, it will act like `default_select`. -# The `default_select` function will simply choose the first match found. -XBLOCK_SELECT_FUNCTION = prefer_xmodules - # .. setting_name: XBLOCK_FIELD_DATA_WRAPPERS # .. setting_default: () # .. setting_description: Paths to wrapper methods which should be applied to every XBlock's FieldData. diff --git a/openedx/core/djangoapps/common_views/xblock.py b/openedx/core/djangoapps/common_views/xblock.py index 6d5f673ef0..ec87b07afb 100644 --- a/openedx/core/djangoapps/common_views/xblock.py +++ b/openedx/core/djangoapps/common_views/xblock.py @@ -6,7 +6,6 @@ Common views dedicated to rendering xblocks. import logging import mimetypes -from django.conf import settings from django.http import Http404, HttpResponse from xblock.core import XBlock @@ -20,7 +19,7 @@ def xblock_resource(request, block_type, uri): # pylint: disable=unused-argumen try: # Figure out what the XBlock class is from the block type, and # then open whatever resource has been requested. - xblock_class = XBlock.load_class(block_type, select=settings.XBLOCK_SELECT_FUNCTION) + xblock_class = XBlock.load_class(block_type) content = xblock_class.open_local_resource(uri) except OSError: log.info('Failed to load xblock resource', exc_info=True) diff --git a/xmodule/modulestore/__init__.py b/xmodule/modulestore/__init__.py index c7224147f0..4b2634484a 100644 --- a/xmodule/modulestore/__init__.py +++ b/xmodule/modulestore/__init__.py @@ -1271,7 +1271,7 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite): result = defaultdict(dict) if fields is None: return result - classes = XBlock.load_class(category, select=prefer_xmodules) + classes = XBlock.load_class(category) cls = self.mixologist.mix(classes) for field_name, value in fields.items(): field = getattr(cls, field_name) @@ -1393,12 +1393,3 @@ def only_xmodules(identifier, entry_points): from_xmodule = [entry_point for entry_point in entry_points if entry_point.dist.key == 'xmodule'] return default_select(identifier, from_xmodule) - - -def prefer_xmodules(identifier, entry_points): - """Prefer entry_points from the xmodule package""" - from_xmodule = [entry_point for entry_point in entry_points if entry_point.dist.key == 'xmodule'] - if from_xmodule: - return default_select(identifier, from_xmodule) - else: - return default_select(identifier, entry_points) diff --git a/xmodule/modulestore/django.py b/xmodule/modulestore/django.py index d5dc316b4f..ead24e6792 100644 --- a/xmodule/modulestore/django.py +++ b/xmodule/modulestore/django.py @@ -305,7 +305,6 @@ def create_modulestore_instance( metadata_inheritance_cache_subsystem=metadata_inheritance_cache, request_cache=request_cache, xblock_mixins=getattr(settings, 'XBLOCK_MIXINS', ()), - xblock_select=getattr(settings, 'XBLOCK_SELECT_FUNCTION', None), xblock_field_data_wrappers=xblock_field_data_wrappers, disabled_xblock_types=fetch_disabled_xblock_types, doc_store_config=doc_store_config, diff --git a/xmodule/modulestore/tests/factories.py b/xmodule/modulestore/tests/factories.py index a7c03b799d..b4e3d5b080 100644 --- a/xmodule/modulestore/tests/factories.py +++ b/xmodule/modulestore/tests/factories.py @@ -22,7 +22,7 @@ from opaque_keys.edx.locator import BlockUsageLocator from xblock.core import XBlock from xmodule.course_module import Textbook -from xmodule.modulestore import ModuleStoreEnum, prefer_xmodules +from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.mixed import strip_key from xmodule.modulestore.tests.sample_courses import TOY_BLOCK_INFO_TREE, default_block_info_tree from xmodule.tabs import CourseTab @@ -389,7 +389,7 @@ class ItemFactory(XModuleFactory): if 'boilerplate' in kwargs: template_id = kwargs.pop('boilerplate') - clz = XBlock.load_class(category, select=prefer_xmodules) + clz = XBlock.load_class(category) template = clz.get_template(template_id) assert template is not None metadata.update(template.get('metadata', {}))