From a9fb82cae6c7f8786bdb29f400591b71cc3c30ab Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 22 Jul 2013 13:20:50 -0400 Subject: [PATCH] Make XModuleDescriptor use the XBlock children API N.B. When we are in a world of mixed XModules and XBlocks, the system/runtime will have to be cognizant of that when asked to return a XModule from an XModuleDescriptor child [#LMS-190] --- common/lib/xmodule/xmodule/x_module.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index fa18d79f77..89f72e8099 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -202,6 +202,13 @@ class XModule(XModuleFields, HTMLSnippet, XBlock): ''' if self._loaded_children is None: child_descriptors = self.get_child_descriptors() + + # This deliberately uses system.get_module, rather than runtime.get_block, + # because we're looking at XModule children, rather than XModuleDescriptor children. + # That means it can use the deprecated XModule apis, rather than future XBlock apis + + # TODO: Once we're in a system where this returns a mix of XModuleDescriptors + # and XBlocks, we're likely to have to change this more children = [self.system.get_module(descriptor) for descriptor in child_descriptors] # get_module returns None if the current user doesn't have access # to the location. @@ -493,7 +500,7 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock): child = child_loc else: try: - child = self.system.load_item(child_loc) + child = self.runtime.get_block(child_loc) except ItemNotFoundError: log.exception('Unable to load item {loc}, skipping'.format(loc=child_loc)) continue @@ -807,6 +814,10 @@ class DescriptorSystem(object): self.resources_fs = resources_fs self.error_tracker = error_tracker + def get_block(self, block_id): + """See documentation for `xblock.runtime:Runtime.get_block`""" + return self.load_item(block_id) + class XMLParsingSystem(DescriptorSystem): def __init__(self, load_item, resources_fs, error_tracker, process_xml, policy, **kwargs):