refactor: rename HiddenDescriptor to HiddenBlock

This also handles the AttributeError in the default XBlock class fallback.
This commit is contained in:
Agrendalath
2022-12-19 16:45:57 +01:00
committed by Piotr Surowiec
parent 3115db5836
commit ae1dcbea74
25 changed files with 45 additions and 48 deletions

View File

@@ -72,7 +72,7 @@
"OPTIONS": {
"collection": "modulestore",
"db": "test",
"default_class": "xmodule.hidden_block.HiddenDescriptor",
"default_class": "xmodule.hidden_block.HiddenBlock",
"fs_root": "** OVERRIDDEN **",
"host": [
"localhost"
@@ -86,7 +86,7 @@
"ENGINE": "xmodule.modulestore.xml.XMLModuleStore",
"OPTIONS": {
"data_dir": "** OVERRIDDEN **",
"default_class": "xmodule.hidden_block.HiddenDescriptor"
"default_class": "xmodule.hidden_block.HiddenBlock"
}
}
]

View File

@@ -105,14 +105,14 @@ MODULESTORE:
OPTIONS:
collection: modulestore
db: test
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: '** OVERRIDDEN **'
host: [localhost]
port: 27017
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
- ENGINE: xmodule.modulestore.xml.XMLModuleStore
NAME: xml
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenDescriptor}
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock}
# We need to test different scenarios, following setting effectively disbale rate limiting
PASSWORD_RESET_IP_RATE: '1/s'
PASSWORD_RESET_EMAIL_RATE: '1/s'

View File

@@ -72,7 +72,7 @@
"OPTIONS": {
"collection": "modulestore",
"db": "test",
"default_class": "xmodule.hidden_block.HiddenDescriptor",
"default_class": "xmodule.hidden_block.HiddenBlock",
"fs_root": "** OVERRIDDEN **",
"host": [
"edx.devstack.mongo"
@@ -86,7 +86,7 @@
"ENGINE": "xmodule.modulestore.xml.XMLModuleStore",
"OPTIONS": {
"data_dir": "** OVERRIDDEN **",
"default_class": "xmodule.hidden_block.HiddenDescriptor"
"default_class": "xmodule.hidden_block.HiddenBlock"
}
}
]

View File

@@ -105,14 +105,14 @@ MODULESTORE:
OPTIONS:
collection: modulestore
db: test
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: '** OVERRIDDEN **'
host: [edx.devstack.mongo]
port: 27017
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
- ENGINE: xmodule.modulestore.xml.XMLModuleStore
NAME: xml
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenDescriptor}
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock}
SECRET_KEY: ''
SERVER_EMAIL: devops@example.com
SESSION_COOKIE_DOMAIN: null

View File

@@ -1005,7 +1005,7 @@ MODULESTORE = {
'ENGINE': 'xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
'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',
}
@@ -1015,7 +1015,7 @@ MODULESTORE = {
'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
'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',
}

View File

@@ -379,7 +379,7 @@ MODULESTORE:
ENGINE: xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore
NAME: split
OPTIONS:
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: /edx/var/edxapp/data
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
- DOC_STORE_CONFIG:
@@ -399,7 +399,7 @@ MODULESTORE:
ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore
NAME: draft
OPTIONS:
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: /edx/var/edxapp/data
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
ORA2_FILE_PREFIX: default_env-default_deployment/ora2

View File

@@ -101,7 +101,7 @@ BLOCK_STRUCTURES_SETTINGS['PRUNING_ACTIVE'] = True
update_module_store_settings(
MODULESTORE,
module_store_options={
'default_class': 'xmodule.hidden_block.HiddenDescriptor',
'default_class': 'xmodule.hidden_block.HiddenBlock',
'fs_root': TEST_ROOT / "data",
},
doc_store_settings={

View File

@@ -2602,7 +2602,7 @@ class TestDisabledXBlockTypes(ModuleStoreTestCase):
def test_get_item(self):
course = CourseFactory()
self._verify_descriptor('video', course, 'HiddenDescriptorWithMixins')
self._verify_descriptor('video', course, 'HiddenBlockWithMixins')
def test_dynamic_updates(self):
"""Tests that the list of disabled xblocks can dynamically update."""
@@ -2615,7 +2615,7 @@ class TestDisabledXBlockTypes(ModuleStoreTestCase):
# Now simulate a new request cache.
self.store.request_cache.data.clear()
self._verify_descriptor('problem', course, 'HiddenDescriptorWithMixins', item_usage_id)
self._verify_descriptor('problem', course, 'HiddenBlockWithMixins', item_usage_id)
def _verify_descriptor(self, category, course, descriptor, item_id=None):
"""

View File

@@ -196,14 +196,14 @@ MODULESTORE:
OPTIONS:
collection: modulestore
db: test
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: '** OVERRIDDEN **'
host: [localhost]
port: 27017
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
- ENGINE: xmodule.modulestore.xml.XMLModuleStore
NAME: xml
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenDescriptor}
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock}
# We need to test different scenarios, following setting effectively disbale rate limiting
PASSWORD_RESET_IP_RATE: '1/s'
PASSWORD_RESET_EMAIL_RATE: '1/s'

View File

@@ -118,14 +118,14 @@ MODULESTORE:
OPTIONS:
collection: modulestore
db: test
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: '** OVERRIDDEN **'
host: [edx.devstack.mongo]
port: 27017
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
- ENGINE: xmodule.modulestore.xml.XMLModuleStore
NAME: xml
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenDescriptor}
OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock}
PASSWORD_RESET_SUPPORT_LINK: https://support.example.com/password-reset-help.html
REGISTRATION_EXTENSION_FORM: openedx.core.djangoapps.user_api.tests.test_helpers.TestCaseForm
REGISTRATION_EXTRA_FIELDS: {city: hidden, country: required, gender: optional, goals: optional,

View File

@@ -1604,7 +1604,7 @@ MODULESTORE = {
'ENGINE': 'xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
'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',
}
@@ -1614,7 +1614,7 @@ MODULESTORE = {
'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
'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',
}

View File

@@ -419,7 +419,7 @@ MODULESTORE:
ENGINE: xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore
NAME: split
OPTIONS:
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: /edx/var/edxapp/data
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
- DOC_STORE_CONFIG:
@@ -439,7 +439,7 @@ MODULESTORE:
ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore
NAME: draft
OPTIONS:
default_class: xmodule.hidden_block.HiddenDescriptor
default_class: xmodule.hidden_block.HiddenBlock
fs_root: /edx/var/edxapp/data
render_template: common.djangoapps.edxmako.shortcuts.render_to_string
OAUTH_DELETE_EXPIRED: true

View File

@@ -17,7 +17,7 @@ XBLOCKS = [
"discuss = xmodule.template_block:TranslateCustomTagBlock",
"discussion = xmodule.discussion_block:DiscussionXBlock",
"error = xmodule.error_block:ErrorBlock",
"hidden = xmodule.hidden_block:HiddenDescriptor",
"hidden = xmodule.hidden_block:HiddenBlock",
"html = xmodule.html_block:HtmlBlock",
"image = xmodule.template_block:TranslateCustomTagBlock",
"library = xmodule.library_root_xblock:LibraryRoot",

View File

@@ -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

View File

@@ -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}"

View File

@@ -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}"

View File

@@ -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',
}

View File

@@ -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'

View File

@@ -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',
}

View File

@@ -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': ''

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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,
)

View File

@@ -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}"

View File

@@ -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