fix: make the initialization more like how it was in the past

This commit is contained in:
Braden MacDonald
2023-05-27 11:57:18 -07:00
parent 018f8f2c7c
commit fbaa2e5a68
6 changed files with 34 additions and 17 deletions

View File

@@ -313,9 +313,22 @@ class XModuleMixin(XModuleFields, XBlock):
def __init__(self, *args, **kwargs):
self._asides = []
# Initialization data used by CachingDescriptorSystem to defer FieldData initialization
self._cds_init_args = kwargs.pop("cds_init_args", None)
super().__init__(*args, **kwargs)
def get_cds_init_args(self):
""" Get initialization data used by CachingDescriptorSystem to defer FieldData initialization """
if self._cds_init_args is None:
raise KeyError("cds_init_args was not provided for this XBlock")
if self._cds_init_args is False:
raise RuntimeError("Tried to get CachingDescriptorSystem cds_init_args twice for the same XBlock.")
args = self._cds_init_args
# Free the memory and set this False to flag any double-access bugs. This only needs to be read once.
self._cds_init_args = False
return args
@property
def runtime(self):
return self._runtime