当前位置: 首页>>代码示例>>Python>>正文


Python ErrorDescriptor.from_descriptor方法代码示例

本文整理汇总了Python中xmodule.error_module.ErrorDescriptor.from_descriptor方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorDescriptor.from_descriptor方法的具体用法?Python ErrorDescriptor.from_descriptor怎么用?Python ErrorDescriptor.from_descriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmodule.error_module.ErrorDescriptor的用法示例。


在下文中一共展示了ErrorDescriptor.from_descriptor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_preview_module

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_descriptor [as 别名]
def load_preview_module(request, preview_id, descriptor):
    """
    Return a preview XModule instantiated from the supplied descriptor.

    request: The active django request
    preview_id (str): An identifier specifying which preview this module is used for
    descriptor: An XModuleDescriptor
    """
    system = preview_module_system(request, preview_id, descriptor)
    try:
        module = descriptor.xmodule(system)
    except:
        log.debug("Unable to load preview module", exc_info=True)
        module = ErrorDescriptor.from_descriptor(descriptor, error_msg=exc_info_to_str(sys.exc_info())).xmodule(system)

    # cdodge: Special case
    if module.location.category == "static_tab":
        module.get_html = wrap_xmodule(module.get_html, module, "xmodule_tab_display.html")
    else:
        module.get_html = wrap_xmodule(module.get_html, module, "xmodule_display.html")

    # we pass a partially bogus course_id as we don't have the RUN information passed yet
    # through the CMS. Also the contentstore is also not RUN-aware at this point in time.
    module.get_html = replace_static_urls(
        module.get_html,
        getattr(module, "data_dir", module.location.course),
        course_id=module.location.org + "/" + module.location.course + "/BOGUS_RUN_REPLACE_WHEN_AVAILABLE",
    )

    module.get_html = save_module(module.get_html, module)

    return module
开发者ID:navdeepgaur,项目名称:edx-platform,代码行数:34,代码来源:preview.py

示例2: test_error_module_from_descriptor

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_descriptor [as 别名]
    def test_error_module_from_descriptor(self):
        descriptor = MagicMock([XModuleDescriptor],
                               runtime=self.system,
                               location=self.location,
                               _field_data=self.valid_xml)

        error_descriptor = ErrorDescriptor.from_descriptor(
            descriptor, self.error_msg)
        self.assertIsInstance(error_descriptor, ErrorDescriptor)
        error_descriptor.xmodule_runtime = self.system
        context_repr = self.system.render(error_descriptor, 'student_view').content
        self.assertIn(self.error_msg, context_repr)
        self.assertIn(repr(descriptor), context_repr)
开发者ID:DavidGrahamFL,项目名称:edx-platform,代码行数:15,代码来源:test_error_module.py

示例3: test_error_module_from_descriptor

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_descriptor [as 别名]
    def test_error_module_from_descriptor(self):
        descriptor = MagicMock(
            spec=XModuleDescriptor,
            runtime=self.system,
            location=self.location,
        )

        error_descriptor = ErrorDescriptor.from_descriptor(
            descriptor, self.error_msg)
        self.assertIsInstance(error_descriptor, ErrorDescriptor)
        error_descriptor.xmodule_runtime = self.system
        context_repr = self.system.render(error_descriptor, STUDENT_VIEW).content
        self.assertIn(self.error_msg, context_repr)
        self.assertIn(repr(descriptor), context_repr)
开发者ID:10clouds,项目名称:edx-platform,代码行数:16,代码来源:test_error_module.py

示例4: load_preview_module

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_descriptor [as 别名]
def load_preview_module(request, preview_id, descriptor):
    """
    Return a preview XModule instantiated from the supplied descriptor.

    request: The active django request
    preview_id (str): An identifier specifying which preview this module is used for
    descriptor: An XModuleDescriptor
    """
    system = preview_module_system(request, preview_id, descriptor)
    try:
        module = descriptor.xmodule(system)
    except:
        log.debug("Unable to load preview module", exc_info=True)
        module = ErrorDescriptor.from_descriptor(
            descriptor,
            error_msg=exc_info_to_str(sys.exc_info())
        ).xmodule(system)

    # cdodge: Special case
    if module.location.category == 'static_tab':
        module.get_html = wrap_xmodule(
            module.get_html,
            module,
            "xmodule_tab_display.html",
        )
    else:
        module.get_html = wrap_xmodule(
            module.get_html,
            module,
            "xmodule_display.html",
        )

    module.get_html = replace_static_urls(
        module.get_html,
        getattr(module, 'data_dir', module.location.course),
        course_namespace=Location([module.location.tag, module.location.org, module.location.course, None, None])
    )

    module.get_html = save_module(
        module.get_html,
        module
    )

    return module
开发者ID:dfnjy,项目名称:edx-platform,代码行数:46,代码来源:preview.py

示例5: load_preview_module

# 需要导入模块: from xmodule.error_module import ErrorDescriptor [as 别名]
# 或者: from xmodule.error_module.ErrorDescriptor import from_descriptor [as 别名]
def load_preview_module(request, preview_id, descriptor):
    """
    Return a preview XModule instantiated from the supplied descriptor.

    request: The active django request
    preview_id (str): An identifier specifying which preview this module is used for
    descriptor: An XModuleDescriptor
    """
    system = preview_module_system(request, preview_id, descriptor)
    try:
        module = descriptor.xmodule(system)
    except:
        log.debug("Unable to load preview module", exc_info=True)
        module = ErrorDescriptor.from_descriptor(
            descriptor,
            error_msg=exc_info_to_str(sys.exc_info())
        ).xmodule(system)

    return module
开发者ID:Cabris,项目名称:edx-platform,代码行数:21,代码来源:preview.py


注:本文中的xmodule.error_module.ErrorDescriptor.from_descriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。