本文整理汇总了Python中forms.EventForm.errors['attachment']方法的典型用法代码示例。如果您正苦于以下问题:Python EventForm.errors['attachment']方法的具体用法?Python EventForm.errors['attachment']怎么用?Python EventForm.errors['attachment']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.EventForm
的用法示例。
在下文中一共展示了EventForm.errors['attachment']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_event
# 需要导入模块: from forms import EventForm [as 别名]
# 或者: from forms.EventForm import errors['attachment'] [as 别名]
def add_event():
def _dup(l):
return [(i, i) for i in l]
session = create_session()
form = EventForm(request.forms.decode())
form.continent.choices = _dup(CONTINENTS)
# countries = session.query(Country) # XXX: why is countries never used?
# form.country.choices = [(c.id, c.name) for c in countries.all()]
# form.gender.choices = _dup(["male", "female", "all"])
if form.validate():
session = create_session()
new_task = Event.from_form(form)
try:
for attachment in scan_attachments(request.files):
print "saving attachment: ", attachment, attachment.filename
new_task.attachments.append(Attachment(
file_path=save_file(attachment),
file_name=attachment.filename,
file_type=attachment.content_type))
session.add(new_task)
session.commit()
return redirect("/")
except InvalidFileUpload as e:
form.errors['attachment'] = e.message
print dict(request.forms)
print form.errors
print type(form.errors)
return new(errors=form.errors)