• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python web.websafe函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: POST

 def POST(self):
     conn =  SQL.sacdb_init().getcon()
     cursor=conn.cursor()
     try:
         ID = web.websafe(web.input().userName)
         pw = web.websafe(web.input().pwd)
         cursor.execute("SELECT * FROM userlist WHERE ID = '%s' and password = '%s'"%(ID,pw))
         if cursor.rowcount ==1:
             V = cursor.fetchone()
             session.login = True
             session.ID = ID
             session.ehour = V[5]
             session.usertype = V[3]
             if session.usertype == 'admin':
                 web.seeother('/admin.html')
             elif session.usertype == 'student':
                 web.seeother('/home.html')
             else:
                 return 'sys error'
         else:
             return failed%'not exist'
     except Exception as e:return failed%str(e)
     finally:
         cursor.close()
         conn.close()
开发者ID:Cabchinoe,项目名称:mistere,代码行数:25,代码来源:login.py


示例2: to_json

 def to_json(self):
     return json_object({
         "date": json_value(web.websafe(self.formatted_date())),
         "author": json_value(web.websafe(self.author)),
         "text": json_value(self.marked_down_text()),
         "line_number": json_value(web.websafe(self.line_number))
     })
开发者ID:rickardlindberg,项目名称:simple-review,代码行数:7,代码来源:domain.py


示例3: get_net_sid_from_id

def get_net_sid_from_id(dataset, id):
    where="dataset=%s AND id=%s" % (websafe(dataset), websafe(id))
    res=list(db.select('network', what='sid', where=where))
    if len(res)==0:
        return None
    else:
        return str(res[0].sid)
开发者ID:AlessiaWent,项目名称:igraph,代码行数:7,代码来源:model.py


示例4: link_to

def link_to(url, caption):
    """Generates a link to the given URL. `caption` is optional and may
    specify the caption of the URL. If `caption` is ``None``, the URL itself
    is used."""
    if caption is None:
        caption = url
    return '<a href="%s">%s</a>' % (websafe(url), websafe(caption))
开发者ID:huandalu,项目名称:igraph,代码行数:7,代码来源:url_helper.py


示例5: GET

	def GET(self):
		paras=web.input(opt_id='-1',val='-1')
		optId=web.websafe(paras.opt_id)
		value=web.websafe(paras.val)
		
		#read the db configuration from file
   	 	path = os.getcwd()+"/db_cnf"
   		#print path
    		f= open(path)
    		lines = f.readlines()
    		for line in lines:
			values = line.split()
			if values[0]=="likelihood":
				LIKELIHOOD_TREESHOLD=values[1]
			elif values[0]=="user":
				U=values[1]
			elif values[0]=="password":
				P=values[1]
			elif values[0]=="db_name":
				DATABASE_NAME=values[1]
			elif values[0]=="host":
				HOST=values[1]
	    		else:
				print "error, unreadable line in configuration file"
				break
	    	f.close()

		print "set parameter..."
		db= MySQLdb.connect(HOST,U,P,DATABASE_NAME)
		cur= db.cursor()
		sql = ('UPDATE Accompany.ActionPossibilityOptions SET SelectedValue=\'%s\' WHERE idActionPossibilityOptions=\'%s\''%(value,optId))		
		cur.execute(sql);
		return "ok"
开发者ID:UH-msalem,项目名称:accompany,代码行数:33,代码来源:DatabaseConnectorWS.py


示例6: POST

    def POST(self):
        if session.login == False or session.usertype != 'student':
            return '''{"success":0}'''
        pageType = web.websafe(web.input().pageType)
        page = web.websafe(web.input().page)
        #ret = Stu().getIndexPage(pageType,page)
        
        if pageType == 0:
            try:
                conn =  SQL.sacdb_init().getcon()
                cursor=conn.cursor()
                sql = "SELECT * FROM activitylist WHERE state=%s ORDER BY posttime DSC LIMIT %s, %s"
                param=(0, page * 5 - 5, page * 5)
                cursor.execute(sql, param)
                data = cursor.fetchall()
                postdata = {"sucess": 1 , "list": []}
                for i in range(0, postdata["pageCnt"]):
                    postdata["list"].append({"AcId": data[i]["ID"], "imgSrc":data[i]["filepath"], "dateTime": data[i]["starttime"], "AcName": data[i]["name"], "AcOrg": data[i]["authorname"], "AcPlace": data[i]["location"], "AcNum": data[i]["maxnum"], "AcNumRest": data[i]["maxnum"] - data[i]["paticipatenum"], "AcHour": data[i]["ehour"]})

                return str(postdata);
            except MySQLdb.Error,e:
                errorinfo =  "indexpage  Mysql Error %d: %s" % (e.args[0], e.args[1])
                return errorinfo
            except Exception as e:
                return 'indexpage  '+str(e)
开发者ID:Cabchinoe,项目名称:mistere,代码行数:25,代码来源:stu.py


示例7: update_filesize

def update_filesize(id, format, size):
    try:
        db.insert('filesize', dataset=int(id), format=websafe(format), 
                  size=int(size))
    except:
        db.update('filesize', where='dataset=%s AND format="%s"' %
                  (int(id), websafe(format)), size=size)
    return True
开发者ID:AlessiaWent,项目名称:igraph,代码行数:8,代码来源:model.py


示例8: POST

 def POST(self):
     if session.login == False or session.usertype != 'admin':
         return '''{"success":0}'''
     pageType = web.websafe(web.input().pageType)
     page = web.websafe(web.input().page)
     ret = admin().getIndexPage(pageType,page)
     
     except Exception as e:
         return "admin_indexpage  "+str(e)
开发者ID:Cabchinoe,项目名称:mistere,代码行数:9,代码来源:admin.py


示例9: GET

    def GET(self):
	web.header('Content-Type', 'text/html')
    	get_vars = web.input()
	response = handler.multiple_update(web.websafe(get_vars.tasks), web.websafe(get_vars.action))
        if response['code'] == '404':
                web.notfound()
        if response['code'] == '410':
                web.gone()
        return response['html']
开发者ID:abiquo,项目名称:workflow-client,代码行数:9,代码来源:webserver.py


示例10: htmlAnalysisRow

def htmlAnalysisRow(analysis, onMap=False, rowClass="", showFloor=True, ageDisplay=None, mapUrl="/mapa"):
    """ Outputs utf-8 encoded HTML with the home analysis.
    Done inside code because of speed up (3-times faster than templetor).
    """
    model = {
        "rowClass": web.websafe(rowClass),
        "url": web.websafe(analysis["url"]),
        "rooms": web.websafe(analysis["rooms"]),
        "price": web.websafe(formatPrice(analysis["price"])),
        "unitPrice": web.websafe(formatPrice(analysis["unitPrice"])),
        "area": analysis["area"],
        "targetAttr": "",
        "extra": "",
    }

    if showFloor:
        model["extra"] = """<td class="n">%s</td>""" % (analysis.get("floor") or "-")
    if ageDisplay is not None:
        if ageDisplay:
            model["extra"] += "<td>%s</td>" % web.websafe(formatAge(analysis["createdDate"]))
        else:
            model["extra"] += "<td></td>"

    if onMap:
        model["targetAttr"] = ' target="_blank"'
    else:
        model["extra"] += """<td class="address"><a href="%s?byt=%s">%s</a></td>""" % (
            web.websafe(mapUrl),
            web.websafe(urlEncode(analysis["url"])),
            web.websafe(analysis["locality"]))


    return """\
<tr class="%(rowClass)s"><td><a href="%(url)s"%(targetAttr)s>%(rooms)s</a></td><td class="n">%(price)s Kč</td><td class="n"><b>%(unitPrice)s Kč/m²</b></td><td class="n">%(area)s m²</td>%(extra)s</tr>
""" % model
开发者ID:fidlej,项目名称:jakybyt,代码行数:35,代码来源:formatter.py


示例11: xmlify

def xmlify(obj):
    if isinstance(obj, bool):
        return ' rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">%s' % web.websafe(obj).lower()
    elif isinstance(obj, int):
        return ' rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">%s' % web.websafe(obj)
    elif isinstance(obj, float):
        return ' rdf:datatype="http://www.w3.org/2001/XMLSchema#double">%s' % web.websafe(obj)
    elif isinstance(obj, URI):
        return ' rdf:resource="%s">' % web.websafe(obj.uri)
    else:
        return '>' + web.websafe(obj)
开发者ID:acgourley,项目名称:watchdog,代码行数:11,代码来源:apipublish.py


示例12: __call__

 def __call__(self, handler):
     i = web.input(_method="GET", _profile="")
     if i._profile.lower() == "true":
         out, result = web.profile(handler)()
         if isinstance(out, web.template.TemplateResult):
             out.__body__ = out.get('__body__', '') + '<pre class="profile">' + web.websafe(result) + '</pre>'
             return out
         elif isinstance(out, basestring):
             return out + '<br/>' + '<pre class="profile">' + web.websafe(result) + '</pre>'
         else:
             # don't know how to handle this.
             return out
     else:
         return handler()
开发者ID:ahvigil,项目名称:openlibrary,代码行数:14,代码来源:processors.py


示例13: GET

    def GET(self):
        receivedData = web.input(url='')
        url = web.websafe(receivedData.url)
        if url!='':
            GPlusStat = GetGPlusStat(url)
            PinterestStat = GetPinterestStat(url)
            FaceResult = GetFaceResult(url)
            TwitterStat = GetTwitterStat(url)
            LinkedInStat = GetLinkedInStat(url)

            TotalStat = 0
            if GPlusStat != 'Error':
                TotalStat += GPlusStat
            if PinterestStat != 'Error':
                TotalStat += PinterestStat
            if FaceResult != 'Error':
                TotalStat += FaceResult
            if TwitterStat != 'Error':
                TotalStat += TwitterStat
            if LinkedInStat != 'Error':
                TotalStat += LinkedInStat

            result = {'GPlus': GPlusStat, 'Pinterest': PinterestStat, 'Facebook': FaceResult, 'Twitter': TwitterStat,
                      'LinkedIn': LinkedInStat, 'Total': TotalStat}

            return json.dumps(result)
        else:
            f = open('statService.wsdl', 'r')
            return f.read()
开发者ID:beeblook,项目名称:NewsStat,代码行数:29,代码来源:Server.py


示例14: POST

    def POST(self):
        s = getSession()

        i = web.input()

        if i.command == "Evaluate":
            inp = ""
            exp = i.expression.rstrip()
            s.history.append(exp)
            s.history_cursor=len(s.history)

            exp = exp.replace('\n', ' ').replace('\r', '')
            
            if assign_pattern.match(exp):
                try:
                    exec(exp, globals(), s.database.transactions[s.database.transactionId])
                    r=""
                except Exception, e:
                    r=e
                    inp=i.expression
            else:
                try:
                    r=eval(exp, globals(), s.database.transactions[s.database.transactionId])
                    if isinstance(r, Relation):
                        r="""<div id="itsthetable">%s</div>""" % r.renderHTML()
                    else:
                        r=str(web.websafe(r))
                except Exception, e:
                    r=e
                    inp=i.expression
开发者ID:bnmnetp,项目名称:dee,代码行数:30,代码来源:DeeWebDemo.py


示例15: f

 def f(*args, **keywords):
     username = None
     password = None
     try:
         b64text = webpy.ctx.env['HTTP_AUTHORIZATION'][6:]
         plaintext = base64.b64decode(b64text)
         colonpos = plaintext.index(':')
         username = plaintext[:colonpos]
         password = plaintext[colonpos + 1:]
     except:
         # TODO: handle absent HTTP_AUTHORIZATION field
         # separately from failed base64 decoding or missing
         # colon in plaintext.
         pass
     if verifier(username, password, realm):
         last_access[username] = datetime.datetime.now()
         # Attach the user's name to the server. The way to
         # find the server depends on whether the function is a
         # bound method.
         if hasattr(func, 'im_self'):
             func.im_self.user = username
         else:
             args[0].user = username
         return func(*args, **keywords)
     else:
         webpy.ctx.status = '401 UNAUTHORIZED'
         webpy.header('WWW-Authenticate',
                      'Basic realm="%s"'  % webpy.websafe(realm))
         return deny(realm, username, password, redirect_url)
开发者ID:attish,项目名称:heapkeeper-old,代码行数:29,代码来源:hkweb.py


示例16: GET

	def GET(self):
		paras = web.input(default_speed='0.0')
		value = web.websafe(paras.default_speed)

		#read the db configuration from file
   	 	path = os.getcwd()+"/db_cnf"
   		#print path
    		f= open(path)
    		lines = f.readlines()
    		for line in lines:
			values = line.split()
			if values[0]=="likelihood":
				LIKELIHOOD_TREESHOLD=values[1]
			elif values[0]=="user":
				U=values[1]
			elif values[0]=="password":
				P=values[1]
			elif values[0]=="db_name":
				DATABASE_NAME=values[1]
			elif values[0]=="host":
				HOST=values[1]
	    		else:
				print "error, unreadable line in configuration file"
				break
	    	f.close()

		print "reset emphasis..."
		db= MySQLdb.connect(HOST,U,P,DATABASE_NAME)
		cur= db.cursor()
		sql = ('UPDATE Accompany.Sensors SET value=\'%s\',lastUpdate=NOW() WHERE sensorId=\'1000\';'%value)		
		cur.execute(sql);
		return "ok"
开发者ID:mbongini,项目名称:accompany,代码行数:32,代码来源:DatabaseConnectorWS.py


示例17: POST

 def POST(self):
     data = web.input()
     try:
         web.sendmail(websafe(data.email), m.User.by_id(1).email, "Blog About Page Contact from: %s" % websafe(data.name), websafe(data.message))
         flash("error","Thanks for Contacting me!")
     except Exception,e:
         flash("error","Sorry, there was a problem, message not sent")
开发者ID:andreztz,项目名称:webpy-bootstrap-blog,代码行数:7,代码来源:app.py


示例18: GET

 def GET(self,url):
     '''view singel page'''
     page = model.get_page_url(url)
     if not page:
         raise web.seeother('/new?url=%s' % web.websafe(url))
     
     return render.view(page)
开发者ID:nianyuguai,项目名称:Python,代码行数:7,代码来源:wiki.py


示例19: get_id_from_sid

def get_id_from_sid(sid):
    res=list(db.select('dataset', what='id', 
                       where="sid='%s'" % websafe(sid)))
    if len(res)==0:
        return None
    else:
        return str(res[0].id)
开发者ID:AlessiaWent,项目名称:igraph,代码行数:7,代码来源:model.py


示例20: do_search_query

def do_search_query(tokens, offset=0, limit=10):

    tokens=[ websafe(t) for t in tokens ]

    if len(tokens)==0:
        return range(1, get_totals().count+1)

    install_regexp()

    searchfields=['name', 'shortdescription', 'description']

    recs=[]
    i=0
    while i < len(tokens):
        if tokens[i] == '-' and i+1 < len(tokens) and tokens[i+1][-1] != ':':
            recs.append( (None, tokens[i+1], True) )
            i += 2
        elif tokens[i] == '-' and i+2 < len(tokens) and \
                tokens[i+1][-1] == ':':
            recs.append( (tokens[i+1][:-1], tokens[i+2], True) )
            i += 3
        elif tokens[i] == '-':
            i += 1
        elif tokens[i][-1] == ':' and i+1 < len(tokens):
            if tokens[i][:-1] in searchfields:
                recs.append( (tokens[i][:-1], tokens[i+1]) )
                i += 2
            else:
                recs.append( (None, tokens[i+1]) )
                i += 2
        else:
            recs.append( (None, tokens[i]) )
            i += 1

    clause="%s %s REGEXP '\\b%s\\b'"

    def allfields(rec):
        if len(rec)>=3 and rec[2]:
            n='NOT'
            op=' AND '
        else:
            n=''
            op=' OR '
        return '(' + op.join([ clause % (f,n,rec[1]) 
                               for f in searchfields]) + ')'

    def term(rec):
        if rec[0] is None:
            return allfields(rec)
        else:
            if len(rec)>=3 and rec[2]:
                n='NOT'
            else:
                n=''
            return clause % (rec[0], n, rec[1])

    where=' AND '.join([ term(r) for r in recs ])
    
    res=db.select('dataset', what='id', where=where)
    return [r.id for r in res]
开发者ID:AlessiaWent,项目名称:igraph,代码行数:60,代码来源:model.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python app.run函数代码示例发布时间:2022-05-26
下一篇:
Python web.verifyLogin函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap