Commit a9fb82ca by Calen Pennington

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]
parent f780369a
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment