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


Python XForm.render方法代码示例

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


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

示例1: set_xmlns_on_form

# 需要导入模块: from corehq.apps.app_manager.xform import XForm [as 别名]
# 或者: from corehq.apps.app_manager.xform.XForm import render [as 别名]
def set_xmlns_on_form(form_id, xmlns, app_build, log_file, dry_run):
    """
    Set the xmlns on a form and all the corresponding forms in the saved builds
    that are copies of app.
    (form is an app_manager.models.Form)
    """
    try:
        form_in_build = app_build.get_form(form_id)
    except FormNotFoundException:
        return

    if form_in_build.xmlns == "undefined" or form_in_build.source.count('xmlns="undefined"') > 0:
        if form_in_build.xmlns != "undefined":
            assert form_in_build.xmlns == xmlns
        xml = form_in_build.source
        wrapped_xml = XForm(xml)

        data = wrapped_xml.data_node.render().decode('utf-8')
        data = data.replace("undefined", xmlns, 1)
        wrapped_xml.instance_node.remove(wrapped_xml.data_node.xml)
        wrapped_xml.instance_node.append(parse_xml(data))
        new_xml = wrapped_xml.render().decode('utf-8')

        form_in_build.source = new_xml
        form_in_build.form_migrated_from_undefined_xmlns = datetime.utcnow()
        log_file.write(
            "New xmlns for form {form_id} in app {app_build._id} is {new_xmlns}\n".format(
                form_id=form_id,
                app_build=app_build,
                new_xmlns=xmlns
            ))
        if not dry_run:
            app_build.save()  # Magic happens on save
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:35,代码来源:fix_forms_and_apps_with_missing_xmlns.py

示例2: save_xform

# 需要导入模块: from corehq.apps.app_manager.xform import XForm [as 别名]
# 或者: from corehq.apps.app_manager.xform.XForm import render [as 别名]
def save_xform(app, form, xml):
    try:
        xform = XForm(xml)
    except XFormError:
        pass
    else:
        duplicates = app.get_xmlns_map()[xform.data_node.tag_xmlns]
        for duplicate in duplicates:
            if form == duplicate:
                continue
            else:
                data = xform.data_node.render()
                xmlns = "http://openrosa.org/formdesigner/%s" % form.get_unique_id()
                data = data.replace(xform.data_node.tag_xmlns, xmlns, 1)
                xform.instance_node.remove(xform.data_node.xml)
                xform.instance_node.append(parse_xml(data))
                xml = xform.render()
                break
    form.source = xml
开发者ID:sravfeyn,项目名称:commcare-hq,代码行数:21,代码来源:util.py

示例3: test_strip_ignore_retain

# 需要导入模块: from corehq.apps.app_manager.xform import XForm [as 别名]
# 或者: from corehq.apps.app_manager.xform.XForm import render [as 别名]
 def test_strip_ignore_retain(self):
     before = self.get_xml("ignore_retain")
     after = self.get_xml("ignore_retain_stripped")
     xform = XForm(before)
     xform.strip_vellum_ns_attributes()
     self.assertXmlEqual(xform.render(), after)
开发者ID:sheelio,项目名称:commcare-hq,代码行数:8,代码来源:test_form_preparation_v2.py


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