zoukankan      html  css  js  c++  java
  • webpy form

    原文http://webpy.org/form

    import web from web import form render = web.template.render('templates/') urls = ('/', 'index') app = web.application(urls, globals()) myform = form.Form( form.Textbox("boe"), form.Textbox("bax", form.notnull, form.regexp('d+', 'Must be a digit'), form.Validator('Must be more than 5', lambda x:int(x)>5)), form.Textarea('moe'), form.Checkbox('curly'), form.Dropdown('french', ['mustard', 'fries', 'wine'])) class index: def GET(self): form = myform() # make sure you create a copy of the form by calling it (line above) # Otherwise changes will appear globally return render.formtest(form) def POST(self): form = myform() if not form.validates(): return render.formtest(form) else: # form.d.boe and form['boe'].value are equivalent ways of # extracting the validated arguments from the form. return "Grrreat success! boe: %s, bax: %s" % (form.d.boe, form['bax'].value) if __name__=="__main__": web.internalerror = web.debugerror app.run()

    And sample formtest.html (place this in the templates subdirectory):

    $def with (form)
    
    <form name="main" method="post"> 
    $if not form.valid: <p class="error">Try again, AmeriCAN:</p>
    $:form.render()
    <input type="submit" />    </form>
  • 相关阅读:
    MySQL根据某一个或者多个字段查找重复数据的sql语句
    常见面试题
    技术总监工作内容
    分布式锁三种实现
    完美解决github访问速度慢
    细说Redis
    Mysql学习的核心问题
    Java反射细说
    Spring中的常见的9种设计模式
    Mybatis相关问题
  • 原文地址:https://www.cnblogs.com/banwhui/p/4600567.html
Copyright © 2011-2022 走看看