本文整理匯總了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)