Exemplo n.º 1
0
    def POST(self):
        inputform = InputForm()
        if not inputform.validates():
            return render.formtest(inputform)
        else:
            # form.d.boe和form ['boe'].value是等价的方式
            # 从表单中提取经过验证的参数。
            sents = inputform.d.input_sentences.split('\r\n')

            r_cents = []
            for sent in sents:
                corrected_sent, err = d.bert_correct(sent)
                r_cents.append(corrected_sent)

            rtform = form.Form(
                # form.Textbox(input_id="foo", name="input_text", value='这是一个测试。'),
                form.Textarea(
                    name='input_sentences',
                    value=inputform.d.input_sentences,
                    style="margin: 0px; width: 310px; height: 187px;"),
                form.Textarea(
                    name='output_sentences',
                    value='\r\n'.join(r_cents),
                    style="margin: 0px; width: 310px; height: 187px;"))
            return render.formtest(
                rtform()
            )  # open(r'./templates/1.html').read() #"Grrreat success! boe: %s, bax: %s" % (form.d.input_text, form.get('input_text').value)
Exemplo n.º 2
0
def BlogUpdateForm(blog):
    """ 博客信息更新表单"""
    def getThemesDirDict(relativePath):
        themesDirDict = []
        dirAbsPath = os.path.abspath(os.path.normpath(relativePath))
        dirlist = os.listdir(dirAbsPath)
        for dir in dirlist:
            path = os.path.join(dirAbsPath, dir)
            if os.path.isdir(path):
                themesDirDict.append((dir, dir))
        return themesDirDict

    newForm = form.Form(
        form.Textbox("blog_name",
                     Validation['notnull'],
                     description=u"名称:",
                     value=blog.name),
        form.Textbox("blog_title",
                     Validation['notnull'],
                     description=u"标题:",
                     value=blog.title),
        form.Textbox("blog_subtitle",
                     Validation['notnull'],
                     description=u"子标题:",
                     value=blog.subtitle),
        form.Textbox("blog_host",
                     Validation['host'],
                     description=u"主机:",
                     value=blog.host),
        form.Dropdown("blog_theme",
                      args=getThemesDirDict('themes'),
                      description=u"主题:",
                      value=blog.theme),
        form.Textarea("blog_description",
                      Validation['notnull'],
                      description=u"描述:",
                      value=blog.description),
        form.Textbox("blog_keywords",
                     Validation['keywords'],
                     description=u"关键字:",
                     value=blog.keywords),
        form.Textarea("blog_announcement",
                      description=u"公告:",
                      value=blog.announcement),
        form.Textbox("blog_pageSize",
                     Validation['number'],
                     description=u"每页显示条数:",
                     value=blog.pageSize),
        form.Textbox("blog_version",
                     readonly="true",
                     description=u"版本:",
                     value=blog.version),
        form.Button("blog_submit", type="submit", html=u'提交'),
    )
    return newForm
Exemplo n.º 3
0
    def make_form(self, pin=None, boards=None):
        boards = boards or []
        boards = [(x.id, x.name) for x in boards]

        if pin is None:
            return form.Form(form.Textbox('name'),
                             form.Textarea('description'),
                             form.Dropdown('board', boards),
                             form.Button('repin'))()
        return form.Form(form.Textbox('name', value=pin.name),
                         form.Textarea('description', value=pin.description),
                         form.Dropdown('board', boards),
                         form.Button('repin'))()
Exemplo n.º 4
0
    def make_form(self, user=None):
        if user is None:
            return form.Form(
                form.Textbox('name'), form.Textbox('username'),
                form.Textarea('about'),
                form.File('profile', description='profile picture'),
                form.Button('save'))

        return form.Form(form.Textbox('name', value=user.name),
                         form.Textbox('username', value=user.username),
                         form.Textarea('about', value=user.about),
                         form.File('profile', description='profile picture'),
                         form.Button('save'))()
Exemplo n.º 5
0
def ArticleUpdateForm(article, categoryDict):
    """ 文章更新表单"""
    updateForm = form.Form(
        form.Hidden("article_id", value=article.key().id()),
        form.Textbox("article_title",
                     Validation['notnull'],
                     description=u"标题:",
                     value=article.title),
        form.Textarea("article_content",
                      Validation['notnull'],
                      description=u"内容:",
                      value=article.content),
        form.Dropdown("article_display",
                      args=[('1', '是'), ('0', '否')],
                      description=u"显示:",
                      value=article.display and "1" or "0"),
        form.Dropdown("article_commentEnable",
                      args=[('1', '是'), ('0', '否')],
                      description=u"允许评论:",
                      value=article.display and "1" or "0"),
        form.Dropdown("article_category",
                      args=categoryDict,
                      description=u"分类:",
                      value=article.category.key().id()),
        form.Button("article_submit", type="submit", html=u'提交'),
    )
    return updateForm
Exemplo n.º 6
0
def BlogerUpdateForm(bloger):
    """ 博主信息更新的表单  """
    newForm = form.Form(
        form.Textbox("bloger_nickname",
                     Validation['notnull'],
                     description=u"昵称:",
                     value=bloger.nickname),
        form.Textbox("bloger_email",
                     Validation['email'],
                     description=u"邮箱:",
                     value=bloger.email),
        form.Dropdown("bloger_sex",
                      args=[('1', '男'), ('0', '女')],
                      value=bloger.sex,
                      description=u"性别:"),
        form.Textbox("bloger_avatar",
                     Validation['url'],
                     description=u"头像:",
                     value=bloger.avatar),
        form.Textarea("bloger_description",
                      Validation['notnull'],
                      description=u"描述:",
                      value=bloger.description),
        form.Button("bloger_submit", type="submit", html=u'提交'),
    )
    return newForm
Exemplo n.º 7
0
 def make_form(self, boards=None):
     boards = boards or []
     boards = [(x.id, x.name) for x in boards]
     return form.Form(form.Textbox('url', id='input-url'),
                      form.Textarea('description', id='input-desc'),
                      form.Dropdown('board', boards),
                      form.Button('add', id='btn-add'))()
Exemplo n.º 8
0
class Contact:
    contact_form = form.Form(
        form.Textbox('name',
                     form.notnull,
                     description="Name",
                     class_='form-control',
                     maxlength_='160',
                     placeholder='Enter your first and last name'),
        form.Email('email',
                   form.notnull,
                   description='Email',
                   id='emailBox',
                   class_='form-control',
                   maxlength_='100',
                   placeholder='Enter your email'),
        form.Textarea('content',
                      form.notnull,
                      description='Questions or Comments',
                      id='passwordBox',
                      class_='form-control',
                      maxlength_='800',
                      style='height: 150px',
                      placeholder='Enter your questions or comments'),
        form.Button('Submit',
                    id='submitButton',
                    class_='btn btn-default btn-block'))

    nullform = form.Form()

    def GET(self):
        form = self.contact_form()
        msg = ''
        err = ''

        render = create_render(session.privilege)
        return render.contact('HMS | Contact', '', form, msg, err)

    def POST(self):
        form = self.contact_form()
        msg = ''
        err = ''

        if not form.validates():
            err = 'Invalid fields.'
        else:
            msg = "Comment was successfully posted."
            self.__helper(form)

        render = create_render(session.privilege)
        return render.contact('HMS | Contact', '', form, msg, err)

    def __helper(self, form):
        cur.execute(
            '''INSERT INTO Comments (name, email, content)
                        VALUES (%s, %s, %s)''',
            (form.d.name, form.d.email, form.d.content))

        # Commit your changes in the database
        db.commit()
Exemplo n.º 9
0
 def alter_article_form(self):
     return form.Form(
         form.Textbox('name',form.notnull,description='Name:',class_="form-control"),
         form.Textbox('title',form.notnull,description='Title:',class_="form-control"),
         form.Textbox('parent',form.notnull,description='parent:',class_="form-control"),
         form.Textbox('has_child_p',form.notnull,description='has_child_p:',class_="form-control"),
         form.Textarea('content',description="Content:",class_="form-control",rows="10"),
         form.Button('submit',type='submit',class_="btn btn-primary"),
         form.Hidden('aid')
     )
Exemplo n.º 10
0
class PageConvo:
    _form = form.Form(form.Textarea('content'))

    def GET(self, convo_id):
        force_login(sess)
        convo_id = int(convo_id)

        convo = db.query('''
            select convos.id, users.id as user_id, users.name from convos
                join users on users.id = (case
                    when convos.id1 = $id then convos.id2
                    else convos.id1
                end)
            where (convos.id = $convo_id and
                   convos.id1 = $id or convos.id2 = $id)''',
                         vars={
                             'convo_id': convo_id,
                             'id': sess.user_id
                         })
        if not convo:
            return 'convo not found'

        messages = db.query('''
            select messages.*, users.name from messages
                join users on users.id = messages.sender
            where messages.convo_id = $convo_id''',
                            vars={'convo_id': convo_id})

        return ltpl('convo', convo[0], messages)

    def POST(self, convo_id):
        force_login(sess)
        convo_id = int(convo_id)

        allowed = bool(
            db.select('convos',
                      what='1',
                      where='id = $cid and (id1 = $id or id2 = $id)',
                      vars={
                          'cid': convo_id,
                          'id': sess.user_id
                      }))
        if not allowed:
            return 'convo not found'

        form = self._form()
        if not form.validates():
            return 'fill everything in'

        db.insert('messages',
                  convo_id=convo_id,
                  sender=sess.user_id,
                  content=form.d.content)
        raise web.seeother('/convo/%d' % convo_id)
Exemplo n.º 11
0
def CommentNewForm(articleID):
    """评论新建表单"""
    newForm = form.Form(
        form.Hidden("comment_article_id",
                    description="article ID:",
                    value=articleID),
        form.Textbox("comment_nickname", description="昵称:"),
        form.Textbox("comment_email", description="邮箱:"),
        form.Textbox("comment_website", description="邮箱:"),
        form.Textarea("comment_content", description="内容:"),
        form.Button("comment_submit", type="submit", html=u'提交'),
    )
    return newForm
Exemplo n.º 12
0
class PagePin:
    _form = form.Form(form.Textarea('comment'))

    def GET(self, pin_id):
        pin_id = int(pin_id)

        pin = db.query('''
            select pins.*, users.name as user_name, users.username as user_username, boards.name as board_name
            from pins
                join boards on boards.id = pins.board_id
                join users on users.id = pins.user_id
            where pins.id = $id''',
                       vars={'id': pin_id})
        if not pin:
            return 'pin not found'

        comments = db.query('''
            select
                comments.*, users.username as user_username, users.name as user_name
            from comments
                join users on users.id = comments.user_id
            where pin_id = $id
            order by timestamp asc''',
                            vars={'id': pin_id})

        rating = db.select('ratings',
                           what='avg(rating)',
                           where='pin_id = $id',
                           vars={'id': pin_id})
        if not rating:
            return 'could not get rating'

        rating = round(rating[0].avg, 2)
        return ltpl('pin', pin[0], comments, rating)

    def POST(self, pin_id):
        force_login(sess)

        pin_id = int(pin_id)
        form = self._form()
        if not form.validates():
            return 'form did not validate'

        if not form.d.comment:
            return 'please write a comment'

        db.insert('comments',
                  pin_id=pin_id,
                  user_id=sess.user_id,
                  comment=form.d.comment)
        raise web.seeother('/pin/%d' % pin_id)
Exemplo n.º 13
0
  def __init__(self, configContext):
    super(EmailCampaignCreate, self).__init__(configContext)
    self.database = db.Database(configContext)
    self.config = configContext

    self.email_form = form.Form(
      form.Textbox('product',    form.notnull),
      form.Textbox('versions',  form.notnull),
      form.Textbox('signature',  form.notnull),
      form.Textbox('subject',    form.notnull),
      form.Textarea('body',      form.notnull),
      form.Textbox('start_date', form.notnull),
      form.Textbox('end_date',   form.notnull),
      form.Textbox('author',     form.notnull))
Exemplo n.º 14
0
    def POST(self):

        messages_form = form.Form(
            form.Textbox('user'),
            form.Textbox('title'),
            form.Textarea('content'),
        )

        form_obj = messages_form()
        if form_obj.validates():
            db.insert(table, **form_obj.d)
            return 'add success'
        else:
            return 'no input'
 def form(self):
     return form.Form(
         form.Dropdown('referee_rating',
                       ('', ('1', '* - Not recommended'),
                        ('2', '** - Has reserve'), ('3', '*** - Average'),
                        ('4', '**** - Strong applicant'),
                        ('5', '***** - Outstanding')),
                       form.notnull,
                       description='How would you score this applicant?'),
         form.Textarea(
             'reference',
             form.notnull,
             description=
             'Please describe in less than 500 words why you recommmend this applicant.'
         ),
         form.Button('submit', type='submit', value='Submit reference'),
     )
Exemplo n.º 16
0
def AlonePageNewForm():
    """ 页面新建表单 """
    newForm = form.Form(
        form.Textbox("page_title", Validation['title'], description="标题:"),
        form.Textbox("page_link", Validation['link'], description="链接:"),
        form.Textarea("page_content", description="内容:"),
        form.Dropdown("page_display",
                      args=[('1', '是'), ('0', '否')],
                      value='1',
                      description="显示:"),
        form.Dropdown("page_commentEnable",
                      args=[('1', '是'), ('0', '否')],
                      value='1',
                      description="允许评论:"),
        form.Button("page_submit", type="submit", html=u'提交'),
    )
    return newForm
Exemplo n.º 17
0
def get_project_form_elements(project_title="", project_description="", category_name=""):
    """
    Generate a set of project form elements
        :param project_title: Project title
        :param project_description: Project description 
        :param category_name: Name of the belonging category
        :type project_title: str
        :type project_description: str
        :type category_name: str
        :return: A set of project form elements    
    """
    categories = get_categories()
    project_form_elements = (
        form.Textbox("project_title", not_empty, description="Title", value=project_title),
        form.Textarea("project_description", not_empty, description="Description", value=project_description),
        form.Dropdown("category_name", description="Category", args=categories)
    )
    return project_form_elements
Exemplo n.º 18
0
def get_task_form_elements(identifier=0, task_title="", task_description="", budget=""):
    """
    Generate a set of task form elements
        :param identifier: The id of the task
        :param task_title: Task title
        :param task_description: Task description 
        :param budget: Task budget
        :type identifier: int, str
        :type task_title: str
        :type task_description: str
        :type budget: int, str
        :return: A set of task form elements
    """
    task_form_elements = (
        form.Textbox("task_title_" + str(identifier), not_empty, description="Task title", value=task_title),
        form.Textarea("task_description_" + str(identifier), not_empty,description="Task description", value=task_description),
        form.Textbox("budget_" + str(identifier), number, description="Task budget", value=str(budget))
    )
    return task_form_elements
Exemplo n.º 19
0
class new_post:
    
    new_post_form = form.Form(
        form.Textbox('title', description='Title: ', size=25), 
        form.Textarea('content', description='Content: ', rows=30, cols=50), 
        form.Button('Submit Post')
    )

    def GET(self):
        new_post_form = self.new_post_form()
        return render.new_post(new_post_form)
        
    def POST(self):
        new_post_form = self.new_post_form()
        if not new_post_form.validates():
            return render.new_post(new_post_form)
        else:
            Posts_Controller.add_post(Blog_Post(new_post_form.d.title, new_post_form.d.content))
            return render.new_post(None)
    def form(self):

        # vemail = form.regexp(r'.+@.+', 'Please enter a valid email address')

        return form.Form(
            form.Checkbox(
                'test_applicants',
                description='Send emails only to test applicants (mlssTest_)?',
                value='1'),
            form.Dropdown(
                'group',
                ('', 'Admitted', 'Rejected',
                 'Scholarship recipients'),  # 'Pending', 'All'),
                form.notnull,
                description='Send emails to'),
            form.Textbox(
                'subject',
                form.notnull,
                description='Subject',
                pre=
                '<label class="help">E.g. [MLSS16] Decision Notification</label>'
            ),
            form.Textarea(
                'body',
                form.notnull,
                description='Body',
                pre=
                "<label class='help'>Take into account that it only the body, the full message starts with 'Dear ApplicantName, ...' and ends with 'Best wishes, ...' </label>"
            ),
            # form.Dropdown('email_template',
            #               ('', 'msg_to_admitted_applicant', 'msg_to_applicant',
            #                'msg_to_applicant_simple', 'msg_notify_applicant'),
            #               form.notnull,
            #               description='Email template'),
            # form.Textbox('subject',
            #              form.notnull,
            #              description='Subject'),
            # form.Textarea('email_body',
            #               form.notnull,
            #               description='Email body'),
            form.Button('submit', type='submit', value='Send emails'),
        )
Exemplo n.º 21
0
def AlonePageUpdateForm(alonePage):
    """ 页面更新表单"""
    updateForm = form.Form(
        form.Hidden("page_id", value=alonePage.id),
        form.Textbox("page_title", description="标题:", value=alonePage.title),
        form.Textbox("page_link", description="链接:", value=alonePage.link),
        form.Textarea("page_content",
                      description="内容:",
                      value=alonePage.content),
        form.Dropdown("page_display",
                      args=[('1', '是'), ('0', '否')],
                      description="显示:",
                      value=alonePage.display and "1" or "0"),
        form.Dropdown("page_commentEnable",
                      args=[('1', '是'), ('0', '否')],
                      description="允许评论:",
                      value=alonePage.commentEnable and "1" or "0"),
        form.Button("page_submit", type="submit", html=u'提交'),
    )
    return updateForm
Exemplo n.º 22
0
 def add_article_form(self):
     return form.Form(
         form.Textbox('name',
                      form.notnull,
                      form.Validator('name already exists.',
                                     lambda x: not articles.name_exist_p(x)),
                      description = 'Name:',
                      class_="form-control"),
         form.Textbox('title',form.notnull,description = 'Title:',class_="form-control"),
         #form.Textbox('parent',description="Parent Name"),
         form.Dropdown('parent',
                       ["NEW_TOPIC"]+articles.get_all_first_level(),
                       form.notnull,
                       description="Parent Name:",
                       class_="form-control"),
         form.Textarea('content',description="Content",class_="form-control",rows="10"),
         form.Button('submit', type='submit', value='OK Publish this article!!',class_="btn btn-primary"),
         validators = [
             form.Validator("Parent Not Exist. If this is a first level article, use 'NEW_TOPIC",
                            lambda i:(i.parent=="NEW_TOPIC" or articles.parent_sans_p(i.parent)))
         ]
     )
Exemplo n.º 23
0
class PageNewBoard:
    _form = form.Form(
        form.Textbox('name'),
        form.Textarea('description'),
        form.Button('create'),
    )

    def GET(self):
        force_login(sess)
        form = self._form()
        return ltpl('addboard', form)

    def POST(self):
        form = self._form()
        if not form.validates():
            return 'you need to fill in everything'

        db.insert('boards',
                  user_id=sess.user_id,
                  name=form.d.name,
                  description=form.d.description)
        raise web.seeother('/boards')
Exemplo n.º 24
0
class edit_post:
    text_form = form.Form(
        form.Textarea('text', description=''),
        form.Button('Submit', type='submit'),
    )

    def GET(self, name):
        f = self.text_form()

        contents = ''
        try:
            with open(contents_dir + name, 'r') as fh:
                contents = fh.read()
        except:
            pass

        if contents:
            f.get('text').value = contents

        # f.get('text').description = name

        return render.edit_post(f, name)

    def POST(self, name):
        f = self.text_form()
        if not f.validates():
            return render.edit_post(f, name)

        text_data = f.get('text').value
        try:
            with open(contents_dir + name, 'w') as fh:
                fh.write(text_data)
        except:
            print 'Failed to write to file!'

        raise web.seeother('/contents/' + name)
Exemplo n.º 25
0
def ArticleNewForm(categoryDict):
    """ 文章新建表单   """
    newForm = form.Form(
        form.Textbox("article_title",
                     Validation['notnull'],
                     description=u"标题:"),
        form.Textarea("article_content",
                      Validation['notnull'],
                      description=u"内容:"),
        form.Dropdown("article_display",
                      args=[('1', '是'), ('0', '否')],
                      value='1',
                      description=u"显示:"),
        form.Dropdown("article_commentEnable",
                      args=[('1', '是'), ('0', '否')],
                      value='1',
                      description=u"允许评论:"),
        form.Dropdown("article_category",
                      args=categoryDict,
                      description=u"分类:"),
        form.Textbox("article_tags", description=u"标签:"),
        form.Button("article_submit", type="submit", html=u'提交'),
    )
    return newForm
Exemplo n.º 26
0
)

app = web.application(urls, globals())

email = re.compile(r'\w+@([a-z]+\.)+[a-z]+')
visa = re.compile(r'[0-9]{4}([\ \-]?)[0-9]{4}([\ \-]?)[0-9]{4}([\ \-]?)[0-9]{4}')

myform = form.Form( 
    form.Textbox('nombre', maxlength="40", description="Nombre:"),
	form.Textbox('apellidos', maxlength="50", description="Apellidos:"),
	form.Textbox('dni', maxlength="9", size="9", description="DNI:"),
	form.Textbox('correo', maxlength="50", size="15", description="Correo Electronico:"),
	form.Dropdown('dia', range(1,32), description="Dia:"),
	form.Dropdown('mes', range(1,13), description="Mes:"),
	form.Dropdown('anio', range(1940,2014), description="Anio:"),
	form.Textarea('direccion', maxlength="55", size="35", description="Direccion:"),	
	form.Password('passw', maxlength="10", size="12", description="Password:"******"10", size="12", description="Repetir:"),
	form.Radio('forma_pago', ['contra reembolso', 'tarjeta visa'], description="Forma de pago:"),
	form.Textbox('numero_visa', maxlength="19", size="20", description="Numero Visa"),
    form.Checkbox('check',
		form.Validator("Debe aceptar las clausulas.", lambda i: "check" not in i), description="Acepto las clausulas"), 
	form.Button('Aceptar'),
	
	
    validators = [
    	form.Validator('El campo nombre no puede estar vacio.', lambda i: len(str(i.nombre))>0),
		form.Validator('El campo apellidos no puede estar vacio.', lambda i: len(str(i.apellidos))>0),
		form.Validator('El campo dni no puede estar vacio.', lambda i: len(str(i.dni))>0),
		form.Validator('El campo correo no puede estar vacio.', lambda i: len(str(i.correo))>0),
		form.Validator('El campo direccion no puede estar vacio.', lambda i: len(str(i.direccion))>0),
Exemplo n.º 27
0
    mailgun.Mailgun.init("MAILGUNAPIUSER")
    mailgun.MailgunMessage.send_txt(
        "MAILGUNADDRESS", email_address, 'Hacker News New Alert Confirmation',
        '''Please confirm your email address: http://hnalert.tk/confirm/''' +
        random_key)


def _get_db_conn():
    conn_string = "host='localhost' dbname='alert_on_change' user='******' password='******'"
    # get a connection, if a connect cannot be made an exception will be raised here
    return psycopg2.connect(conn_string)


myform = form.Form(
    form.Textarea(
        "string",
        description='String to look for (case-insensitive), eg: "bitcoin"'),
    form.Textbox("email_address",
                 description='email address to send alert to.'),
    form.Textarea("description",
                  description='Description of what this is for.'),
)


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.form(form)
Exemplo n.º 28
0
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

from borrar import *
from web import form
import os.path
from time import time


formulariop = form.Form( 

    form.Textbox("nombre", description = "Nombre:", value=""),
    form.Textarea("sugerencia", description = "Haz una sugerencia para la asignatura de IV:", value=""),
    form.Button("Enviar"),
) 


class Formulario:        
   
    def GET(self):
        form = formulariop()  
        html = """
        <html>
          <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>PON TUS SUGERENCIAS PARA IV</title>
            <link rel="stylesheet" href="static/comun.css">
            <link rel="stylesheet" href="static/estilo.css">
Exemplo n.º 29
0
petitionform = form.Form(
    form.Textbox('ptitle',
                 form.Validator("Title can't be blank", bool),
                 description="Title:",
                 size='80'),
    form.Textbox('pid',
                 form.Validator("Address can't be blank", bool),
                 form.Validator('ID already exists, Choose a different one.',
                                petitionnotexists),
                 pre='http://watchdog.net/c/',
                 description='URL:',
                 size='30'),
    form.Textarea('msg',
                  form.Validator("Description can't be blank", bool),
                  description="Description:",
                  rows='15',
                  cols='80'),
    form.Checkbox('tocongress', value='', description="Petition to Congress?"),
    form.Hidden('userid'))

wyrform = form.Form(
    form.Dropdown('prefix', ['Mr.', 'Mrs.', 'Dr.', 'Ms.', 'Miss'],
                  description='Prefix'),
    form.Textbox('lname',
                 form.Validator("Last name can't be blank", bool),
                 size='16',
                 description='Last Name'),
    form.Textbox('fname',
                 form.Validator("First name can't be blank", bool),
                 size='16',
Exemplo n.º 30
0
from web import form

render = web.template.render('templates/', base='base')

urls = ('/', 'index')
app = web.application(urls, globals())

myform = form.Form(
    form.Textbox("Nombre"),
    form.Textbox("Telefono", form.notnull, form.regexp('\d+',
                                                       'Must be a digit'),
                 form.Validator('Must be more than 5', lambda x: int(x) > 5)),
    form.Textbox(
        "Nacimiento", form.notnull, form.regexp('\d+', 'Must be a digit'),
        form.Validator('No puede ser mayor a 2016', lambda x: int(x) < 2016)),
    form.Textarea('Email'), form.Checkbox('INE', value='INE'),
    form.Dropdown('Genero', ['Macho Alfa', 'Mujer']))


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: