当前位置: 首页>>代码示例>>Python>>正文


Python forms.Form类代码示例

本文整理汇总了Python中forms.Form的典型用法代码示例。如果您正苦于以下问题:Python Form类的具体用法?Python Form怎么用?Python Form使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

    def main(self, message='', **kwargs):
        store = filedict_con(cfg.store_file, 'sys')

        defaults = {'wan_admin': "''",
                    'wan_ssh': "''",
                    'lan_ssh': "''",
                    }
        for k,c in defaults.items():
            if not k in kwargs:
                try:
                    kwargs[k] = store[k]
                except KeyError:
                    exec("if not '%(k)s' in kwargs: store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {'k':k, 'c':c})

        form = Form(title=_("Accessing the %s" % cfg.box_name), 
                        action="/sys/config/wan", 
                        name="admin_wan_form",
                        message=message )
        form.html(self.help())
        if cfg.users.expert():
            form.checkbox(_("Allow access to Plinth from WAN"), name="wan_admin", checked=kwargs['wan_admin'])
            form.checkbox(_("Allow SSH access from LAN"), name="lan_ssh", checked=kwargs['lan_ssh'])
            form.checkbox(_("Allow SSH access from WAN"), name="wan_ssh", checked=kwargs['wan_ssh'])
        form.submit(_("Submit"))
        return form.render()
开发者ID:Keith2,项目名称:Plinth,代码行数:25,代码来源:wan.py

示例2: categories_edit

def categories_edit(category_id):
    try:
        category = Category.find_by_id(category_id)
        if category:
            if request.method == 'GET':
                category_dict = category.__dict__
                form = Form(category_dict, form_fields)
                return render_template('category/edit.html', form=form, category_id=category_id, success=True)
            elif request.method == 'POST':
                form = Form(request.form, form_fields)
                if form.validate():
                    values = form.named_values()
                    category.from_dict(values)
                    category.save()
                    miner = miner_cls(category)
                    miners[category_id] = miner
                    miner.start()
                    return redirect(url_for('categories'))
                else:
                    return render_template('category/edit.html', form=form, category_id=category_id, success=True)
            elif request.method == 'DELETE':
                miner = miners[category_id]
                miner.stop()
                del miners[category_id]
                Category.delete(category_id)
                return 'Category {} deleted.'.format(category_id), 200
            else:
                return 'Unsupported request method.', 400
        else:
            return 'Category {} not found.'.format(category_id), 400
    except ValueError, e:
        print e
        return '{} is not a valid category id.'.format(category_id), 400
开发者ID:tirami,项目名称:udadisi-google-scholar,代码行数:33,代码来源:views.py

示例3: racimos_faltantes

def racimos_faltantes():
    form = Form(request.form)
    _populated_select(form)
    if form.type.data =='1':
        cur.execute("SELECT id, peso, item, fecha, orden, cod_empacadora, peso_neto, peso_bruto, cod_item_corto, cod_hacienda, "
                    "ROUND(AVG(peso),2) as promedio, COUNT(orden) as total_cajas, cantidad, ROUND(MIN(peso),2) as minimo, "
                    "ROUND(MAX(peso),2) as maximo, ROUND(AVG(peso_bruto),2) as promedio_bruto FROM caja ")
    if form.type.data =='2':
        cur.execute("SELECT id, peso, item, fecha, orden, cod_empacadora, peso_neto, peso_bruto, cod_item_corto, cod_hacienda, "
                    "ROUND(AVG(peso),2) as promedio, COUNT(orden) as total_cajas, cantidad, ROUND(MIN(peso),2) as minimo, "
                    "ROUND(MAX(peso),2) as maximo, ROUND(AVG(peso_bruto),2) as promedio_bruto "
                    "FROM bandeja WHERE DATE(fecha)='$fecha_consulta' GROUP BY orden, cod_item_corto ORDER BY "
                    "cod_empacadora, orden")
    if form.type.data =='3':
        cur.execute("SELECT r.idracimo, r.idconvoy, r.peso, r.timestamp as fecha_racimo, r.numlote as lote_racimo, "
                    "r.cinta, r.edad, r.cod_empacadora, r.cod_hacienda, r.tara, c.timestamp as fecha_convoy,c.num_racimos, "
                    "c.cuadrilla, COUNT(peso) as cantidad_pesada, ROUND(AVG(tara),2) as prom_tara, "
                    "ROUND(MIN(CAST(peso AS DECIMAL)),2) as minimo, ROUND(MAX(CAST(peso AS DECIMAL)),2) as maximo, "
                    "ROUND(AVG(CAST(peso AS DECIMAL)),2) as peso_promedio from racimo r left join convoy c ON(r.idconvoy=c.idconvoy) "
                    "WHERE DATE(r.timestamp)='"+form.date.data+"' GROUP BY r.idconvoy, r.numlote, r.cinta")
        cur.execute("SELECT r.idracimo, r.idconvoy, r.peso, r.timestamp as fecha_racimo, r.numlote as lote_racimo, "
                    "r.cinta, r.edad, r.cod_empacadora, r.cod_hacienda, r.tara, c.timestamp as fecha_convoy,c.num_racimos, "
                    "c.cuadrilla, COUNT(peso) as cantidad_pesada, ROUND(AVG(tara),2) as prom_tara, "
                    "ROUND(MIN(CAST(peso AS DECIMAL)),2) as minimo, ROUND(MAX(CAST(peso AS DECIMAL)),2) as maximo, "
                    "ROUND(AVG(CAST(peso AS DECIMAL)),2) as peso_promedio from racimo r left join convoy c ON(r.idconvoy=c.idconvoy) "
                    "WHERE DATE(r.timestamp)='"+form.date.data+"' GROUP BY r.cinta")
    if not form.type.data == 'None':
        data= cur.fetchall()
    else:
        data= []
    if not form.validate_on_submit():
        flash('Ingresar bien todos los campos')
    return render_template('racimos_faltantes.html',form=form, data=data)
开发者ID:Manexware,项目名称:reybanpac_rb_report,代码行数:33,代码来源:__init__.py

示例4: fill_form_and_submit

    def fill_form_and_submit(self, elm, data={}):
        """
        Fill form with given data, then submit

        :param elm: Form element
        :param data: Dictionary of data for the form. \
                Keys in the dictionary represent name \
                attributes of the form elements
        """
        form = Form(elm)
        form.fill_out_and_submit(data)
开发者ID:jirikuchta,项目名称:selenium-webtests,代码行数:11,代码来源:webdriver.py

示例5: skriv

def skriv(request):
    data = {}
    if request.method == "POST":
        form = Form(data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('gastbok'))
    else:
        form = Form(initial={'spamcheck': 'Sto'})
    data['form'] = form
    return render(request, 'guestbook/skriv.html', data)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例6: form

def form(request):
    if request.method == 'POST':
        form = Form(request.POST)
        if form.is_valid():
            return render_to_response('form.html',{'m':'woo hoo'})
    else:
        form = Form()

    return render_to_response('form.html', {
        'form': form,
    })
开发者ID:Fandekasp,项目名称:django-math-captcha,代码行数:11,代码来源:views.py

示例7: on_submit

	def on_submit(self):
		Form.on_submit(self)
		localdir = self.content["Local Dir?"].get()
		portnum = self.content["Port Number"].get()
		filename = self.content["File Name"].get()
		servername = self.content["Server Name"].get() 
		if localdir:
			os.chdir(localdir)
		portnum = int(portnum)
		getfile.client(servername, portnum, filename)
		showinfo("getfilegui-3", "Download Complete")
		if self.one_shot: Tk().quit()
开发者ID:abrarisme,项目名称:RandomPyCode,代码行数:12,代码来源:getfilegui-3.py

示例8: main

 def main(self, msg=''):
     users = cfg.users.keys()
     add_form = Form(title=_("Edit or Delete User"), action="/sys/users/edit", message=msg)
     add_form.html('<span class="indent"><strong>Delete</strong><br /></span>')
     for uname in sorted(users.keys()):
         add_form.html('<span class="indent">&nbsp;&nbsp;%s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' % 
                       add_form.get_checkbox(name=uname) +
                       '<a href="/sys/users/edit?username=%s">%s (%s)</a><br /></span>' % 
                       (uname, users[uname]['name'], uname))
     add_form.submit(label=_("Delete User"), name="delete")
     return add_form.render()
开发者ID:Keith2,项目名称:Plinth,代码行数:11,代码来源:users.py

示例9: main

 def main(self, msg=''):
     users = cfg.users.get_all()
     add_form = Form(title=_("Edit or Delete User"), action=cfg.server_dir + "/sys/users/edit", message=msg)
     add_form.html('<span class="indent"><strong>Delete</strong><br /></span>')
     for uname in users:
         user = User(uname[1])
         add_form.html('<span class="indent">&nbsp;&nbsp;%s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' %
                       add_form.get_checkbox(name=user['username']) +
                       '<a href="'+cfg.server_dir+'/sys/users/edit?username=%s">%s (%s)</a><br /></span>' %
                       (user['username'], user['name'], user['username']))
     add_form.submit(label=_("Delete User"), name="delete")
     return add_form.render()
开发者ID:NickDaly,项目名称:plinth-debian-package,代码行数:12,代码来源:users.py

示例10: main

 def main(self, username='', message=None, *args, **kwargs):
     form = Form(title="Register XMPP Account",
                 action=cfg.server_dir + "/services/xmpp/register/index",
                 name="register_xmpp_form",
                 message=message)
     form.text_input(_("Username"), name="username", value=username)
     form.text_input(_("Password"), name="password", type="password")
     form.submit(label=_("Register XMPP Account"), name="register")
     return form.render()
开发者ID:NickDaly,项目名称:plinth-debian-package,代码行数:9,代码来源:xmpp.py

示例11: diff

def diff(request):
    base_result = ''
    new_result = ''
    if request.method == 'POST':
        form = Form(request.POST)
        if form.is_valid():
            base_url = form.cleaned_data['base_url']
            new_url = form.cleaned_data['new_url']
            query = form.cleaned_data['query']
            if base_url != '' and new_url != '' and query != '':
                base_result = urllib2.urlopen("%s%s" % (base_url.encode('utf8'), query.encode('utf8'))).read()
                if base_result != '':
                    base_result = simplejson.loads(base_result)['records']
                new_result = urllib2.urlopen("%s%s" % (new_url.encode('utf8'), query.encode('utf8'))).read()
                if new_result != '':
                    new_result = simplejson.loads(new_result)['records']
                print base_result
    else:
        form = Form()

    return render_to_response('diff.html', {'form': form, 'base_result': base_result, 'new_result': new_result}, context_instance=RequestContext(request))
开发者ID:David-Q,项目名称:cjdq-legend-site,代码行数:21,代码来源:views.py

示例12: main

 def main(self, expert=None, message='', **kwargs):
     """Note that kwargs contains '':"submit" if this is coming
     from a submitted form.  If kwargs is empty, it's a fresh form
     with no user input, which means it should just reflect the
     state of the stored data."""
     if not kwargs and expert == None:
         expert = cfg.users.expert()
         cfg.log("Expert mode is %s" % expert)
     form = Form(title=_("Expert Mode"), 
                     action="/sys/config/experts", 
                     name="expert_mode_form",
                     message=message )
     form.html(self.help())
     form.checkbox(_("Expert Mode"), name="expert", checked=expert)
     form.submit(_("Submit"))
     return form.render()
开发者ID:copyninja,项目名称:Plinth,代码行数:16,代码来源:expert_mode.py

示例13: categories_edit

def categories_edit(category_id):
    try:
        category = Category.find_by_id(category_id)
        if category:
            if request.method == "GET":
                category_dict = category.__dict__
                form = Form(category_dict, form_fields)
                return render_template("category/edit.html", form=form, category_id=category_id, success=True)
            elif request.method == "POST":
                form = Form(request.form, form_fields)
                if form.validate():
                    values = form.named_values()
                    category.from_dict(values)
                    category.save()
                    miner = miner_cls(category)
                    miners[category_id] = miner
                    miner.start()
                    return redirect(url_for("categories"))
                else:
                    return render_template("category/edit.html", form=form, category_id=category_id, success=True)
            elif request.method == "DELETE":
                if category_id in miners:
                    miner = miners[category_id]
                    miner.stop()
                    del miners[category_id]
                    Category.delete(category_id)
                    return "Category {} deleted.".format(category_id), 200
                else:
                    return "Category {} not present on miner.".format(category_id), 400
            else:
                return "Unsupported request method.", 400
        else:
            return "Category {} not found.".format(category_id), 400
    except ValueError, e:
        print e
        return "{} is not a valid category id.".format(category_id), 400
开发者ID:tirami,项目名称:udadisi-rss,代码行数:36,代码来源:views.py

示例14: __init__

    def __init__(self, name, **kwargs):
        super(BaseCrud, self).__init__()
        self.name=name
        self.pk_type='int'
        self.navigation_hint=name+'.list'
        self.form=[]
        self.label=name.capitalize()
        self.url='/{0}/'.format(name)
        self.parent=None
        self.labels={}
        self.list_columns=[]
        self.form=Form()
        self.collection=None


        if 'pk_type' in kwargs: self.pk_type=kwargs['pk_type'] 
        if 'navigation_hint' in kwargs: self.navigation_hint=kwargs['navigation_hint'] 
        if 'label' in kwargs: self.label=kwargs['label'] 
        if 'url' in kwargs: self.url=kwargs['url'] 
        if 'labels' in kwargs: self.labels=kwargs['labels'] 
        if 'list_columns' in kwargs:
            self.list_columns=create_columns(kwargs['list_columns'])
        if 'form' in kwargs: 
            self.form=create_form(kwargs['form'],self.labels)  
开发者ID:artfh,项目名称:flask-crud,代码行数:24,代码来源:crud.py

示例15: main

    def main(self, wan_ip0=0, wan_ip1=0, wan_ip2=0, wan_ip3=0, 
             subnet0=0, subnet1=0, subnet2=0, subnet3=0, 
             gateway0=0, gateway1=0, gateway2=0, gateway3=0, 
             dns10=0, dns11=0, dns12=0, dns13=0, 
             dns20=0, dns21=0, dns22=0, dns23=0, 
             dns30=0, dns31=0, dns32=0, dns33=0, 
             message=None, **kwargs):
        if not cfg.users.expert():
            return ''

        store = filedict_con(cfg.store_file, 'router')
        defaults = {'connect_type': "'DHCP'",
                    }
        for k,c in defaults.items():
            if not k in kwargs:
                try:
                    kwargs[k] = store[k]
                except KeyError:
                    exec("if not '%(k)s' in kwargs: store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {'k':k, 'c':c})

        form = Form(title="WAN Connection", 
                        action="/router/setup/wan/index", 
                        name="wan_connection_form",
                        message=message)
        form.dropdown('Connection Type', vals=["DHCP", "Static IP"], id="connect_type", onchange="hideshow_static()")
        form.html('<div id="static_ip_form">')
        form.dotted_quad("WAN IP Address", name="wan_ip", quad=[wan_ip0, wan_ip1, wan_ip2, wan_ip3])
        form.dotted_quad("Subnet Mask", name="subnet", quad=[subnet0, subnet1, subnet2, subnet3])
        form.dotted_quad("Gateway", name="gateway", quad=[gateway0, gateway1, gateway2, gateway3])
        form.dotted_quad("Static DNS 1", name="dns1", quad=[dns10, dns11, dns12, dns13])
        form.dotted_quad("Static DNS 2", name="dns2", quad=[dns20, dns21, dns22, dns23])
        form.dotted_quad("Static DNS 3", name="dns3", quad=[dns30, dns31, dns32, dns33])
        form.html('</div>')
        form.html("""  <script LANGUAGE="JavaScript">
    <!--
      hideshow_static();
    // --> 
  </script>""")
        form.submit("Set Wan")
        return form.render()
开发者ID:copiesofcopies,项目名称:Plinth,代码行数:40,代码来源:router.py


注:本文中的forms.Form类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。