我想用html写表格,比如
form    
    input type.....   
    input type.....    
然后在py中写这个:
f = forms.register_form()
if not f.validates():
    return render.register(f)
问题是,如果表单没有通过验证,我该如何将信息反馈给用户。速度上有没有像#springbind这样的东西?
让我用我的一个 web.py 项目的片段来回答:
bookeditform = form.Form(
    form.Textbox('title', form.notnull),
    form.Textbox('author', form.notnull),
    form.Textbox('year', 
        form.Validator('Must be a number', lambda x: not x or int(x) > 0)),
)
# ...
class NewBookHandler:
    def GET(self):
        f = bookeditform()
        return render.bookedit(f, "New book")
    def POST(self):
        f = bookeditform()
        if f.validates():
            newid = db.insert('book', title=f.d.title, 
                              author=f.d.author, year=f.d.year)
            raise web.seeother('/book/%s' % newid)
        else:
            return render.bookedit(f, "New book")
回顾:
GET,只需呈现空表单。POST,加载表单,并检查其是否有效。 
POST,因为用户可以刷新页面,重新执行相同的操作。