From 59757ee52d8482ee79e3a2e7a4bf69f62b9e55f5 Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Mon, 5 Dec 2022 16:10:05 +0530 Subject: [PATCH] refactor: replace xmodule.load_item calls with get_block --- xmodule/conditional_block.py | 2 +- xmodule/modulestore/mongo/base.py | 2 +- xmodule/modulestore/tests/test_mixed_modulestore.py | 2 +- xmodule/modulestore/xml.py | 4 ++-- xmodule/template_block.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index e4e8d54dd8..fbc2944dfc 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -326,7 +326,7 @@ class ConditionalBlock( descriptors = [] for location in self.sources_list: try: - descriptor = self.system.load_item(location) + descriptor = self.system.get_block(location) descriptors.append(descriptor) except ItemNotFoundError: msg = "Invalid module by location." diff --git a/xmodule/modulestore/mongo/base.py b/xmodule/modulestore/mongo/base.py index a8fa670e47..93e09dda3c 100644 --- a/xmodule/modulestore/mongo/base.py +++ b/xmodule/modulestore/mongo/base.py @@ -824,7 +824,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo system = using_descriptor_system system.module_data.update(data_cache) - item = system.load_item(location, for_parent=for_parent) + item = system.get_block(location, for_parent=for_parent) # TODO Once TNL-5092 is implemented, we can remove the following line # of code. Until then, set the course_version field on the block to be diff --git a/xmodule/modulestore/tests/test_mixed_modulestore.py b/xmodule/modulestore/tests/test_mixed_modulestore.py index 0f32988962..21c25347ba 100644 --- a/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -448,7 +448,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): assert block.course_version == course_version # ensure that when the block is retrieved from the runtime cache, # the course version is still present - cached_block = course.runtime.load_item(block.location) + cached_block = course.runtime.get_block(block.location) assert cached_block.course_version == block.course_version @ddt.data((ModuleStoreEnum.Type.split, 2, False), (ModuleStoreEnum.Type.mongo, 3, True)) diff --git a/xmodule/modulestore/xml.py b/xmodule/modulestore/xml.py index d621d6c477..35c5244c13 100644 --- a/xmodule/modulestore/xml.py +++ b/xmodule/modulestore/xml.py @@ -639,7 +639,7 @@ class XMLModuleStore(ModuleStoreReadBase): else: try: # get and update data field in xblock runtime - module = system.load_item(loc) + module = system.get_block(loc) for key, value in data_content.items(): setattr(module, key, value) module.save() @@ -653,7 +653,7 @@ class XMLModuleStore(ModuleStoreReadBase): # html file with html data content html = f.read() try: - module = system.load_item(loc) + module = system.get_block(loc) module.data = html module.save() except ItemNotFoundError: diff --git a/xmodule/template_block.py b/xmodule/template_block.py index 2d2d6a5313..2c542ba4fc 100644 --- a/xmodule/template_block.py +++ b/xmodule/template_block.py @@ -111,7 +111,7 @@ class CustomTagBlock(CustomTagTemplateBlock): # pylint: disable=abstract-method # cdodge: look up the template as a module template_loc = self.location.replace(category='custom_tag_template', name=template_name) - template_block = system.load_item(template_loc) + template_block = system.get_block(template_loc) template_block_data = template_block.data template = Template(template_block_data) return template.safe_substitute(params)