Commit d7e44108 by Ned Batchelder

Adjust parameters to construct_xblock_from_class to match XBlock repo.

parent e73bc906
...@@ -105,10 +105,10 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor): ...@@ -105,10 +105,10 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor):
}) })
return system.construct_xblock_from_class( return system.construct_xblock_from_class(
cls, cls,
field_data,
# The error module doesn't use scoped data, and thus doesn't need # The error module doesn't use scoped data, and thus doesn't need
# real scope keys # real scope keys
ScopeIds('error', None, location, location) ScopeIds('error', None, location, location),
field_data,
) )
def get_context(self): def get_context(self):
......
...@@ -193,7 +193,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -193,7 +193,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
field_data = DbModel(kvs) field_data = DbModel(kvs)
scope_ids = ScopeIds(None, category, location, location) scope_ids = ScopeIds(None, category, location, location)
module = self.construct_xblock_from_class(class_, field_data, scope_ids) module = self.construct_xblock_from_class(class_, scope_ids, field_data)
if self.cached_metadata is not None: if self.cached_metadata is not None:
# parent container pointers don't differentiate between draft and non-draft # parent container pointers don't differentiate between draft and non-draft
# so when we do the lookup, we should do so with a non-draft location # so when we do the lookup, we should do so with a non-draft location
...@@ -621,12 +621,11 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -621,12 +621,11 @@ class MongoModuleStore(ModuleStoreBase):
dbmodel = self._create_new_field_data(location.category, location, definition_data, metadata) dbmodel = self._create_new_field_data(location.category, location, definition_data, metadata)
xmodule = system.construct_xblock_from_class( xmodule = system.construct_xblock_from_class(
xblock_class, xblock_class,
dbmodel,
# We're loading a descriptor, so student_id is meaningless # We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet, # We also don't have separate notions of definition and usage ids yet,
# so we use the location for both. # so we use the location for both.
ScopeIds(None, location.category, location, location) ScopeIds(None, location.category, location, location),
dbmodel,
) )
# decache any pending field settings from init # decache any pending field settings from init
xmodule.save() xmodule.save()
......
...@@ -111,8 +111,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -111,8 +111,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
try: try:
module = self.construct_xblock_from_class( module = self.construct_xblock_from_class(
class_, class_,
ScopeIds(None, json_data.get('category'), definition_id, block_locator),
field_data, field_data,
ScopeIds(None, json_data.get('category'), definition_id, block_locator)
) )
except Exception: except Exception:
log.warning("Failed to load descriptor", exc_info=True) log.warning("Failed to load descriptor", exc_info=True)
......
...@@ -477,11 +477,11 @@ class XMLModuleStore(ModuleStoreBase): ...@@ -477,11 +477,11 @@ class XMLModuleStore(ModuleStoreBase):
loc = Location('i4x', course_descriptor.location.org, course_descriptor.location.course, category, slug) loc = Location('i4x', course_descriptor.location.org, course_descriptor.location.course, category, slug)
module = system.construct_xblock_from_class( module = system.construct_xblock_from_class(
HtmlDescriptor, HtmlDescriptor,
DictFieldData({'data': html, 'location': loc, 'category': category}),
# We're loading a descriptor, so student_id is meaningless # We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet, # We also don't have separate notions of definition and usage ids yet,
# so we use the location for both # so we use the location for both
ScopeIds(None, category, loc, loc), ScopeIds(None, category, loc, loc),
DictFieldData({'data': html, 'location': loc, 'category': category}),
) )
# VS[compat]: # VS[compat]:
# Hack because we need to pull in the 'display_name' for static tabs (because we need to edit them) # Hack because we need to pull in the 'display_name' for static tabs (because we need to edit them)
......
...@@ -46,8 +46,8 @@ class TabsEditingDescriptorTestCase(unittest.TestCase): ...@@ -46,8 +46,8 @@ class TabsEditingDescriptorTestCase(unittest.TestCase):
TabsEditingDescriptor.tabs = self.tabs TabsEditingDescriptor.tabs = self.tabs
self.descriptor = system.construct_xblock_from_class( self.descriptor = system.construct_xblock_from_class(
TabsEditingDescriptor, TabsEditingDescriptor,
field_data=DictFieldData({}),
scope_ids=ScopeIds(None, None, None, None), scope_ids=ScopeIds(None, None, None, None),
field_data=DictFieldData({}),
) )
def test_get_css(self): def test_get_css(self):
......
...@@ -133,8 +133,8 @@ class VideoDescriptorTest(unittest.TestCase): ...@@ -133,8 +133,8 @@ class VideoDescriptorTest(unittest.TestCase):
system = get_test_descriptor_system() system = get_test_descriptor_system()
self.descriptor = system.construct_xblock_from_class( self.descriptor = system.construct_xblock_from_class(
VideoDescriptor, VideoDescriptor,
field_data=DictFieldData({}),
scope_ids=ScopeIds(None, None, None, None), scope_ids=ScopeIds(None, None, None, None),
field_data=DictFieldData({}),
) )
def test_get_context(self): def test_get_context(self):
......
...@@ -87,8 +87,8 @@ class TestXBlockWrapper(object): ...@@ -87,8 +87,8 @@ class TestXBlockWrapper(object):
runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs) runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
return runtime.construct_xblock_from_class( return runtime.construct_xblock_from_class(
descriptor_cls, descriptor_cls,
ScopeIds(None, descriptor_cls.__name__, location, location),
DictFieldData({}), DictFieldData({}),
ScopeIds(None, descriptor_cls.__name__, location, location)
) )
def leaf_module(self, descriptor_cls): def leaf_module(self, descriptor_cls):
...@@ -109,10 +109,10 @@ class TestXBlockWrapper(object): ...@@ -109,10 +109,10 @@ class TestXBlockWrapper(object):
runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs) runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs)
return runtime.construct_xblock_from_class( return runtime.construct_xblock_from_class(
descriptor_cls, descriptor_cls,
ScopeIds(None, descriptor_cls.__name__, location, location),
DictFieldData({ DictFieldData({
'children': range(3) 'children': range(3)
}), }),
ScopeIds(None, descriptor_cls.__name__, location, location)
) )
def container_module(self, descriptor_cls, depth): def container_module(self, descriptor_cls, depth):
......
...@@ -166,8 +166,8 @@ class EditableMetadataFieldsTest(unittest.TestCase): ...@@ -166,8 +166,8 @@ class EditableMetadataFieldsTest(unittest.TestCase):
runtime = get_test_descriptor_system() runtime = get_test_descriptor_system()
return runtime.construct_xblock_from_class( return runtime.construct_xblock_from_class(
XmlDescriptor, XmlDescriptor,
scope_ids=Mock(),
field_data=field_data, field_data=field_data,
scope_ids=Mock()
).editable_metadata_fields ).editable_metadata_fields
def get_descriptor(self, field_data): def get_descriptor(self, field_data):
......
...@@ -247,12 +247,11 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor ...@@ -247,12 +247,11 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor
field_data = DbModel(kvs) field_data = DbModel(kvs)
video = system.construct_xblock_from_class( video = system.construct_xblock_from_class(
cls, cls,
field_data,
# We're loading a descriptor, so student_id is meaningless # We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet, # We also don't have separate notions of definition and usage ids yet,
# so we use the location for both # so we use the location for both
ScopeIds(None, location.category, location, location) ScopeIds(None, location.category, location, location),
field_data,
) )
return video return video
......
...@@ -502,8 +502,8 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock): ...@@ -502,8 +502,8 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
module = system.construct_xblock_from_class( module = system.construct_xblock_from_class(
self.module_class, self.module_class,
descriptor=self, descriptor=self,
field_data=system.xmodule_field_data(self),
scope_ids=self.scope_ids, scope_ids=self.scope_ids,
field_data=system.xmodule_field_data(self),
) )
module.save() module.save()
return module return module
......
...@@ -339,12 +339,11 @@ class XmlDescriptor(XModuleDescriptor): ...@@ -339,12 +339,11 @@ class XmlDescriptor(XModuleDescriptor):
return system.construct_xblock_from_class( return system.construct_xblock_from_class(
cls, cls,
field_data,
# We're loading a descriptor, so student_id is meaningless # We're loading a descriptor, so student_id is meaningless
# We also don't have separate notions of definition and usage ids yet, # We also don't have separate notions of definition and usage ids yet,
# so we use the location for both # so we use the location for both
ScopeIds(None, location.category, location, location) ScopeIds(None, location.category, location, location),
field_data,
) )
@classmethod @classmethod
......
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