本文整理汇总了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"))
示例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"])