refactor: rename HiddenDescriptor to HiddenBlock
This also handles the AttributeError in the default XBlock class fallback.
This commit is contained in:
committed by
Piotr Surowiec
parent
3115db5836
commit
ae1dcbea74
@@ -13,7 +13,7 @@ from xmodule.x_module import (
|
||||
|
||||
|
||||
@XBlock.needs("i18n")
|
||||
class HiddenDescriptor(
|
||||
class HiddenBlock(
|
||||
RawMixin,
|
||||
XmlMixin,
|
||||
XModuleToXBlockMixin,
|
||||
@@ -22,9 +22,6 @@ class HiddenDescriptor(
|
||||
"""
|
||||
XBlock class loaded by the runtime when another XBlock type has been disabled
|
||||
or an unknown XBlock type is included in a course import.
|
||||
|
||||
The class name includes 'Descriptor' because this used to be an XModule and the class path is specified in the
|
||||
modulestore config in a number of places.
|
||||
"""
|
||||
HIDDEN = True
|
||||
has_author_view = True
|
||||
|
||||
@@ -523,9 +523,9 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
|
||||
module_path, _, class_name = default_class.rpartition('.')
|
||||
try:
|
||||
class_ = getattr(import_module(module_path), class_name)
|
||||
except ImportError:
|
||||
except (ImportError, AttributeError):
|
||||
fallback_module_path = "xmodule.hidden_block"
|
||||
fallback_class_name = "HiddenDescriptor"
|
||||
fallback_class_name = "HiddenBlock"
|
||||
log.exception(
|
||||
"Failed to import the default store class. "
|
||||
f"Falling back to {fallback_module_path}.{fallback_class_name}"
|
||||
|
||||
@@ -658,9 +658,9 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
|
||||
module_path, __, class_name = default_class.rpartition('.')
|
||||
try:
|
||||
class_ = getattr(import_module(module_path), class_name)
|
||||
except ImportError:
|
||||
except (ImportError, AttributeError):
|
||||
fallback_module_path = "xmodule.hidden_block"
|
||||
fallback_class_name = "HiddenDescriptor"
|
||||
fallback_class_name = "HiddenBlock"
|
||||
log.exception(
|
||||
"Failed to import the default store class. "
|
||||
f"Falling back to {fallback_module_path}.{fallback_class_name}"
|
||||
|
||||
@@ -76,7 +76,7 @@ def mixed_store_config(data_dir, mappings, store_order=None, modulestore_options
|
||||
store_order = [StoreConstructors.draft, StoreConstructors.split]
|
||||
|
||||
options = {
|
||||
'default_class': 'xmodule.hidden_block.HiddenDescriptor',
|
||||
'default_class': 'xmodule.hidden_block.HiddenBlock',
|
||||
'fs_root': data_dir,
|
||||
'render_template': 'common.djangoapps.edxmako.shortcuts.render_to_string',
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class CommonMixedModuleStoreSetup(CourseComparisonTest):
|
||||
COLLECTION = 'modulestore'
|
||||
ASSET_COLLECTION = 'assetstore'
|
||||
FS_ROOT = DATA_DIR
|
||||
DEFAULT_CLASS = 'xmodule.hidden_block.HiddenDescriptor'
|
||||
DEFAULT_CLASS = 'xmodule.hidden_block.HiddenBlock'
|
||||
RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': ''
|
||||
|
||||
MONGO_COURSEID = 'MITx/999/2013_Spring'
|
||||
|
||||
@@ -28,7 +28,7 @@ class ModuleStoreSettingsMigration(TestCase):
|
||||
"ENGINE": "xmodule.modulestore.xml.XMLModuleStore",
|
||||
"OPTIONS": {
|
||||
"data_dir": "directory",
|
||||
"default_class": "xmodule.hidden_block.HiddenDescriptor",
|
||||
"default_class": "xmodule.hidden_block.HiddenBlock",
|
||||
},
|
||||
"DOC_STORE_CONFIG": {},
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class ModuleStoreSettingsMigration(TestCase):
|
||||
"OPTIONS": {
|
||||
"collection": "modulestore",
|
||||
"db": "edxapp",
|
||||
"default_class": "xmodule.hidden_block.HiddenDescriptor",
|
||||
"default_class": "xmodule.hidden_block.HiddenBlock",
|
||||
"fs_root": mkdtemp_clean(),
|
||||
"host": "localhost",
|
||||
"password": "password",
|
||||
@@ -64,7 +64,7 @@ class ModuleStoreSettingsMigration(TestCase):
|
||||
"OPTIONS": {
|
||||
"collection": "modulestore",
|
||||
"db": "test",
|
||||
"default_class": "xmodule.hidden_block.HiddenDescriptor",
|
||||
"default_class": "xmodule.hidden_block.HiddenBlock",
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
@@ -79,7 +79,7 @@ class ModuleStoreSettingsMigration(TestCase):
|
||||
"ENGINE": "xmodule.modulestore.xml.XMLModuleStore",
|
||||
"OPTIONS": {
|
||||
"data_dir": "directory",
|
||||
"default_class": "xmodule.hidden_block.HiddenDescriptor"
|
||||
"default_class": "xmodule.hidden_block.HiddenBlock"
|
||||
},
|
||||
"DOC_STORE_CONFIG": {}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class ModuleStoreSettingsMigration(TestCase):
|
||||
'ENGINE': 'xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore',
|
||||
'DOC_STORE_CONFIG': {},
|
||||
'OPTIONS': {
|
||||
'default_class': 'xmodule.hidden_block.HiddenDescriptor',
|
||||
'default_class': 'xmodule.hidden_block.HiddenBlock',
|
||||
'fs_root': "fs_root",
|
||||
'render_template': 'common.djangoapps.edxmako.shortcuts.render_to_string',
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class ModuleStoreSettingsMigration(TestCase):
|
||||
'ENGINE': 'xmodule.modulestore.mongo.draft.DraftModuleStore',
|
||||
'DOC_STORE_CONFIG': {},
|
||||
'OPTIONS': {
|
||||
'default_class': 'xmodule.hidden_block.HiddenDescriptor',
|
||||
'default_class': 'xmodule.hidden_block.HiddenBlock',
|
||||
'fs_root': "fs_root",
|
||||
'render_template': 'common.djangoapps.edxmako.shortcuts.render_to_string',
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ DB = 'test_mongo_%s' % uuid4().hex[:5]
|
||||
COLLECTION = 'modulestore'
|
||||
ASSET_COLLECTION = 'assetstore'
|
||||
FS_ROOT = DATA_DIR # TODO (vshnayder): will need a real fs_root for testing load_item
|
||||
DEFAULT_CLASS = 'xmodule.hidden_block.HiddenDescriptor'
|
||||
DEFAULT_CLASS = 'xmodule.hidden_block.HiddenBlock'
|
||||
RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': ''
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class SplitModuleTest(unittest.TestCase):
|
||||
'collection': 'modulestore',
|
||||
}
|
||||
modulestore_options = {
|
||||
'default_class': 'xmodule.hidden_block.HiddenDescriptor',
|
||||
'default_class': 'xmodule.hidden_block.HiddenBlock',
|
||||
'fs_root': tempdir.mkdtemp_clean(),
|
||||
'xblock_mixins': (InheritanceMixin, XModuleMixin, EditInfoMixin)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class SplitWMongoCourseBootstrapper(unittest.TestCase):
|
||||
}
|
||||
|
||||
modulestore_options = {
|
||||
'default_class': 'xmodule.hidden_block.HiddenDescriptor',
|
||||
'default_class': 'xmodule.hidden_block.HiddenBlock',
|
||||
'fs_root': '',
|
||||
'render_template': mock.Mock(return_value=""),
|
||||
'xblock_mixins': (InheritanceMixin, XModuleMixin)
|
||||
|
||||
@@ -342,7 +342,7 @@ class XmlModulestoreBuilder(StoreBuilderBase):
|
||||
modulestore = XMLModuleStore(
|
||||
DATA_DIR,
|
||||
course_ids=course_ids,
|
||||
default_class='xmodule.hidden_block.HiddenDescriptor',
|
||||
default_class='xmodule.hidden_block.HiddenBlock',
|
||||
xblock_mixins=XBLOCK_MIXINS,
|
||||
)
|
||||
|
||||
|
||||
@@ -337,9 +337,9 @@ class XMLModuleStore(ModuleStoreReadBase):
|
||||
module_path, _, class_name = default_class.rpartition('.')
|
||||
try:
|
||||
class_ = getattr(import_module(module_path), class_name)
|
||||
except ImportError:
|
||||
except (ImportError, AttributeError):
|
||||
fallback_module_path = "xmodule.hidden_block"
|
||||
fallback_class_name = "HiddenDescriptor"
|
||||
fallback_class_name = "HiddenBlock"
|
||||
log.exception(
|
||||
"Failed to import the default store class. "
|
||||
f"Falling back to {fallback_module_path}.{fallback_class_name}"
|
||||
|
||||
@@ -260,7 +260,7 @@ class ImportManager:
|
||||
|
||||
def __init__(
|
||||
self, store, user_id, data_dir, source_dirs=None,
|
||||
default_class='xmodule.hidden_block.HiddenDescriptor',
|
||||
default_class='xmodule.hidden_block.HiddenBlock',
|
||||
load_error_modules=True, static_content_store=None,
|
||||
target_id=None, verbose=False,
|
||||
do_import_static=True, do_import_python_lib=True,
|
||||
@@ -1229,7 +1229,7 @@ def validate_course_policy(module_store, course_id):
|
||||
|
||||
def perform_xlint( # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
data_dir, source_dirs,
|
||||
default_class='xmodule.hidden_block.HiddenDescriptor',
|
||||
default_class='xmodule.hidden_block.HiddenBlock',
|
||||
load_error_modules=True,
|
||||
xblock_mixins=(LocationMixin, XModuleMixin)):
|
||||
err_cnt = 0
|
||||
|
||||
Reference in New Issue
Block a user