diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 92776eabd8..709d81046e 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -191,6 +191,26 @@ class XModuleMixin(XBlockMixin): default=None ) + def __init__(self, *args, **kwargs): + self.xmodule_runtime = None + super(XModuleMixin, self).__init__(*args, **kwargs) + + @property + def runtime(self): + # Handle XModule backwards compatibility. If this is a pure + # XBlock, and it has an xmodule_runtime defined, then we're in + # an XModule context, not an XModuleDescriptor context, + # so we should use the xmodule_runtime (ModuleSystem) as the runtime. + if (not isinstance(self, (XModule, XModuleDescriptor)) and + self.xmodule_runtime is not None): + return self.xmodule_runtime + return self._runtime + + @runtime.setter + def runtime(self, value): + self._runtime = value + + @property def system(self): """ @@ -1168,9 +1188,8 @@ class DescriptorSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # p return super(DescriptorSystem, self).render(block, view_name, context) def handler_url(self, block, handler_name, suffix='', query='', thirdparty=False): - xmodule_runtime = getattr(block, 'xmodule_runtime', None) - if xmodule_runtime is not None: - return xmodule_runtime.handler_url(block, handler_name, suffix, query, thirdparty) + if block.xmodule_runtime is not None: + return block.xmodule_runtime.handler_url(block, handler_name, suffix, query, thirdparty) else: # Currently, Modulestore is responsible for instantiating DescriptorSystems # This means that LMS/CMS don't have a way to define a subclass of DescriptorSystem @@ -1182,9 +1201,8 @@ class DescriptorSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # p """ See :meth:`xblock.runtime.Runtime:local_resource_url` for documentation. """ - xmodule_runtime = getattr(block, 'xmodule_runtime', None) - if xmodule_runtime is not None: - return xmodule_runtime.local_resource_url(block, uri) + if block.xmodule_runtime is not None: + return block.xmodule_runtime.local_resource_url(block, uri) else: # Currently, Modulestore is responsible for instantiating DescriptorSystems # This means that LMS/CMS don't have a way to define a subclass of DescriptorSystem @@ -1202,9 +1220,8 @@ class DescriptorSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # p """ See :meth:`xblock.runtime.Runtime:publish` for documentation. """ - xmodule_runtime = getattr(block, 'xmodule_runtime', None) - if xmodule_runtime is not None: - return xmodule_runtime.publish(block, event_type, event) + if block.xmodule_runtime is not None: + return block.xmodule_runtime.publish(block, event_type, event) def add_block_as_child_node(self, block, node): child = etree.SubElement(node, "unknown") diff --git a/requirements/edx/github.txt b/requirements/edx/github.txt index c12c8293d9..3b40143eef 100644 --- a/requirements/edx/github.txt +++ b/requirements/edx/github.txt @@ -20,7 +20,7 @@ -e git+https://github.com/pmitros/django-pyfs.git@d175715e0fe3367ec0f1ee429c242d603f6e8b10#egg=djpyfs # Our libraries: --e git+https://github.com/edx/XBlock.git@81a6d713c98d4914af96a0ca624ee7fa4903625e#egg=XBlock +-e git+https://github.com/edx/XBlock.git@246811773c67a84fdb17614a8e9f7ec7b1890574#egg=XBlock -e git+https://github.com/edx/codejail.git@66dd5a45e5072666ff9a70c768576e9ffd1daa4b#egg=codejail -e git+https://github.com/edx/diff-cover.git@v0.5.0#egg=diff_cover -e git+https://github.com/edx/js-test-tool.git@v0.1.5#egg=js_test_tool