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


Python Form.is_error方法代码示例

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


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

示例1: visit_save_view

# 需要导入模块: from pyramid_simpleform import Form [as 别名]
# 或者: from pyramid_simpleform.Form import is_error [as 别名]
def visit_save_view(request):
    health_id = request.matchdict["health_id"]
    form_id = request.matchdict["form"]
    visit_date = request.POST["visit_date"]
    health_unit = request.POST["health_unit"]
    observations = []

    person = None
    with transaction.manager:
        person = models.DBSession.query(models.Person).filter(models.Person.health_id == health_id).first()

    form = Form(request, schema=VisitSchema())
    if form.validate():
        for param, value in request.POST.iteritems():
            try:
                param = int(param)
                print param, value, "\n"
                with transaction.manager:
                    concept = models.DBSession.query(models.Concept).get(param)
                    if concept:
                        observation = models.Observation()
                        observation.concept = param
                        observation.concept_value
                        observations.append(observation)
            except ValueError:
                continue

        visit = form.bind(models.Visit())
        visit.person = person.id
        visit.observations = observations
        models.DBSession.add(visit)
        models.DBSession.flush()
        # with transaction.manager:
        #    visit.observations = observations
        #    models.DBSession.merge(visit)
    else:
        # print form.all_errors()
        print form.is_error(visit_date)
    print request.POST
    return HTTPFound(request.route_url("patients_list_page"))
开发者ID:etoko,项目名称:longitudinal_register,代码行数:42,代码来源:visits.py

示例2: test_validate_bad_input_with_validators

# 需要导入模块: from pyramid_simpleform import Form [as 别名]
# 或者: from pyramid_simpleform.Form import is_error [as 别名]
    def test_validate_bad_input_with_validators(self):
        from pyramid_simpleform import Form

        request = testing.DummyRequest()
        request.method = "POST"

        form = Form(request, validators=dict(name=validators.NotEmpty()))

        self.assert_(not form.validate())
        self.assert_(form.is_validated)
        self.assert_(form.is_error("name"))

        self.assert_(form.errors_for("name") == ["Please enter a value"])
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:15,代码来源:tests.py


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