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

Python web.debug函数代码示例

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

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



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

示例1: db_body

        def db_body(db):

            srow = DatabaseSessionStateProvider.set_msg_context(self, manager, context, sessionids, db)

            if srow:
                # set oauth-related extensions on context
                context.session.token_type = srow.token_type
                context.session.secret = srow.secret
                context.session.client_secret = srow.client_secret

                if srow.aux_json != None:
                    aux = jsonReader(srow.aux_json)
                else:
                    aux = None

                context.session.aux = aux

                data_store = Oauth1aDataStore(context.session)
                oauth_server = oauth.oauth.OAuthServer(data_store)
                oauth_server.add_signature_method(oauth.oauth.OAuthSignatureMethod_HMAC_SHA1())
    
                try:
                    oauth_server.verify_request(context.oauth_request)
                except oauth.oauth.OAuthError, te:
                    if hasattr(te, 'message'):
                        web.debug(te.message)
                    # clear session-related state on invalid signature
                    context.oauth_request = None
                    context.client = None
                    context.attributes = set()
                    context.session = None
开发者ID:kylechard,项目名称:webauthn,代码行数:31,代码来源:oauth1a.py


示例2: process

    def process(self):
        userSession = web.ctx.env.get('HTTP_X_CURRENT_PERSONID') 
        params = web.data()
        jsons = simplejson.loads(params if params else '{}')
        web.debug('Notify userSession: %s, %r' % (userSession, jsons))
        if not userSession:
                web.ctx.status = '406 Not login'
                return 'not userID'   
        remove = True
        startPage = 0
        pageSize = 30
        if 'keep' in jsons:
            remove = jsons['keep']
        
        if 'startPage' in jsons:
            startPage = jsons['startPage']
        
        if 'pageSize' in jsons:
            pageSize = jsons['pageSize']

        query = {'personID':userSession,}
        if remove:
            query = {'personID':userSession, 'remove':{'$ne':'1'}}
        
        notes = MongoUtil.fetchPage('notes',query,startPage,pageSize,[('createdTime', -1)])
        #web.debug('notes count:%i' % len(notes))
        res = []
        for note in notes:
           if maturedNote(note):
               if remove:
                   note['remove'] = '1'
                   MongoUtil.update('notes', note)
               res.append(cleanNote(note))
        web.debug('Total friend:'+ str(len(res)))
        return simplejson.dumps(res)        
开发者ID:tianwalker2012,项目名称:handpa,代码行数:35,代码来源:notify.py


示例3: handle_user

def handle_user(user_email, password, function_type):
	try:
		check_username = globs.db.query("SELECT * FROM users WHERE email=$id", vars={'id':user_email})
		print "CHECK USERNAME!!!!!!!!!!!!"
		print check_username
		if (function_type == "register"):
			if not list(check_username):
				pass_hashobj = globs.PasswordHash(password)
				email_hashobj = globs.PasswordHash(user_email)
				user_ident = globs.db.query ("SELECT MAX(user_id) as highestId from users")[0]

				if (user_ident.highestId == None):
					userID = 0
				else:
					userID = user_ident.highestId + 1

				sequence_id = globs.db.insert('users',  user_id = userID, email = user_email, active = 0, password_hash = pass_hashobj.hashedpw, password_salt = pass_hashobj.salt, create_date = web.SQLLiteral("NOW()"), email_hash = email_hashobj.hashedpw, email_salt = email_hashobj.salt)
			else:
				print "I occur when the login username is already taken"
				return False
		elif (function_type == "login"):
			results = check_username[0]
			verified = globs.verify_user_hash(password, results)
			return verified

			
			
		else:
			print "I shouldn't occur"
			return False
	except IndexError:
		web.debug("AN SQL EXCEPTION HAS OCCURED")
		return False		
开发者ID:lreznick,项目名称:legalcitation,代码行数:33,代码来源:dbConnector.py


示例4: POST

    def POST(self):
        raw_data = web.data()
        conn, cursor = oraconn()

        web.header("Content-Type", "application/json")

        try:
            data = json.loads(raw_data)
        except:
            return '{"success": false, "message": "Failed to decode json string"}'

        try:
            data["ma"]["datum"] = datetime.datetime.strptime(data["ma"]["datum"], "%d.%m.%Y")
        except:
            return "Failed to parse input date"

            # web.debug(data["ma"])

            # update metadata

        sql = "SELECT DATUM FROM DATO_HOLDINGAREA_STAFF WHERE DATUM = TO_DATE('%s', 'YYYYMMDD')" % data["ma"][
            "datum"
        ].strftime("%Y%m%d")
        web.debug(sql)
        try:
            cursor.execute(sql)
        except Exception, e:
            # web.debug(e)
            return '{"success": false, "message": "Failed to query metadata in database"}'
开发者ID:wunderlins,项目名称:ha,代码行数:29,代码来源:webctx.py


示例5: POST

 def POST(self):
     data = web.data()
     (_, tmp_key) = data.split('=')
     web.debug(tmp_key)
     key = ""
     for s in tmp_key:
         if s.isdigit() or s.isalpha():
             key += s 
     if len(key) == 0:
         render = web.template.render(tmpt_path, base='layout')
         return render.view_video("")
     else: 
         res = gen_formats(key)
         if len(res) == 0:
             ret = '<h2>Warning</h2>' + '<pre><code>'
             ret += "No available video" + '<br>'
             ret += '</code></pre>' 
             render = web.template.render(tmpt_path, base='layout')
             return render.view_video(ret)
         else:
             ret = '<h2>Enjoy it!</h2> <br><br>'
             for r in res:
                 tmp  = r.split('_')
                 tmp  = tmp[len(tmp)-1].replace('.mp4', '')
                 w, h = tmp.split('x')
                 ret  += "<video width=\"" + w + "\" height=\"" + h + "\" controls>"
                 ret  += "<source src=\""  + r + "\" type=\"video/mp4\">"
                 ret  += "</video>"
                 ret  += "<br><br><br>"
             render = web.template.render(tmpt_path, base='layout')
             return render.view_video(ret)
开发者ID:cap-ntu,项目名称:Morph,代码行数:31,代码来源:redirect.py


示例6: getNextCommand

 def getNextCommand(self):
   web.debug("current floor %d" % self._currentFloor)
   web.debug("stops up:" + " - ".join(str(s) for s in self._stopsUp))
   web.debug("stops down:" + " - ".join(str(s) for s in self._stopsDown))
   web.debug("stops:" + " - ".join(str(s) for s in self._stopsDown))
   #if the current floor is in the stops no matter the firection
   if self._currentFloor in self._stops:
     self._openDoors()
   #checking the stops when going up
   elif self._currentDirection == ElevatorEngine.DIRECTION_UP and self._currentFloor in self._stopsUp:
     self._openDoors()
   #checking the stops when going down
   elif self._currentDirection == ElevatorEngine.DIRECTION_DOWN and self._currentFloor in self._stopsDown:
     self._openDoors()
   #checking in the current direction (to avoid going up/down everytime)
   elif self._numberOfStopsInDirection(self._currentDirection) != 0:
     self._goToCurrentDirection()
   #checking the other direction
   elif self._numberOfStopsInDirection(self._reverseCurrentDirection()) != 0:
     self._goToCurrentReverseDirection()
     
   ##Doing the action
   if self._actions.empty():
     action = ElevatorEngine.ACTION_NOTHING
   else:
     action = self._actions.get()
   web.debug("action: %s" % (action))
   return action
开发者ID:coupain,项目名称:cs-s01-e01,代码行数:28,代码来源:elevator_engine_baptiste.py


示例7: POST

    def POST(self):
        x = web.input(myfile={})
        web.debug(x['myfile'].filename)
        #web.debug(x['myfile'].value)
        web.debug(x['myfile'].file.read())

        raise web.seeother('/upload')
开发者ID:marvinyane,项目名称:pythonStudy,代码行数:7,代码来源:upload.py


示例8: doGet

def doGet(pathInfo, opts):
    """Does HTTP GET"""

    web.debug("doGet")

    # Quick /entity/search for property:value
    # Looks up entity and returns
    if pathInfo == "/get":
        httpConfig = httpconfig.HttpConfig(web.ctx.env["DOCUMENT_ROOT"])
        host = httpConfig.config["serverhost"]
        port = httpConfig.config["serverport"]
        prop = "urn:lri:property_type:id"
        val = opts["id"]
        url = 'http://%s:%s/entity/search?q={"%s":"%s"}&opts={}' % (host, port, prop, val)
        web.debug("doGet: url = " + url)
        r = requests.get(url)

        text = None
        try:
            text = r.content
        except AttributeError, e:
            print ("doGet: No content")

            try:
                text = r.text
            except AttributeError, e:
                print ("doGet: No text")
开发者ID:ravi4every1,项目名称:legacy-projects,代码行数:27,代码来源:ccss.py


示例9: filterPruned

    def filterPruned(self, properties, key):
        """Returns data w/all keys removed but id and given properties

Works on filtered results

"""
        # Get all properties
        props = []
        for item in self.get("response"):
            for i in item[key]:
                for prop in i["props"].keys():
                    if prop not in props:
                        props.append(prop)

        # Keep props we want to keep
        # Start with props that are never removed
        # Add props passed in
        keeps = self.getDefaultFilterProps()
        for prop in properties:
            if prop not in keeps:
                keeps.append(prop)

        # Remove props we want to keep from list
        for keep in keeps:
            try:
                props.remove(keep)
            except ValueError, e:
                web.debug("QueryResult.filterPruned: %s: %r" % (keep, e))
开发者ID:ravi4every1,项目名称:legacy-projects,代码行数:28,代码来源:ccss.py


示例10: GET

 def GET(self):
     q = web.input()
     t = template.env.get_template('search.html')
     f = search_form()
     try:
         if q.query:
             results = []
             user_list = []
             query = q.query.split(' ')
             for i in User.all():
                 x = util.strip_private_data(i)
                 if x is not None:
                     user_list.append(x)
             for p in user_list:
                 for i in query:
                     if i in dict(p).values():
                         results.append(p)
             return t.render(util.data(
                 title='Find who you\'re looking for!',
                 form=f,
                 results=results if results else None,
             ))
         else:
             web.debug('q.query doesn\'t exist and it didn\'t thow an exception!')
             raise Warning('Odd, huh?')
     except:
         return t.render(util.data(
             title='Find who you\'re looking for!',
             form=f,
         ))
开发者ID:ikon42,项目名称:reddit-unite,代码行数:30,代码来源:directory_app.py


示例11: POST

	def POST(self):
		registroForm = FormularioRegistro()
		if not registroForm.validates():
			return makos.mako_template(varDep = "",titulo = self.paginaActual, formRegistro = registroForm )
		else:
			datos = web.input()
			conn = MongoClient('mongodb://localhost:27017')
			db = conn.app.usuarios
			aux = web.input()

			db_usuarios = {
				"nombre": aux.Nombre,
				"apellidos": aux.Apellidos,
				"email": aux.Email,
				"visa": aux.Visa,
				"dia": aux.Dia,
				"mes": aux.Mes,
				"ano": aux.Ano,
				"direccion": aux.Direccion,
				"contrasena": aux.Contrasena,
				"contrasena2": aux.Contrasena2,
				"pago": aux.Pago,
			}

			db.insert(db_usuarios)

			#Cerramos la conexión
			conn.close()
			datos = leerDatosBD()
			registroForm = insertarDatosForm(datos)
			web.debug(datos)
			contenido = imprimirDatosBD()
			return makos.mako_template(varDep = "", titulo = self.paginaActual, formRegistro = registroForm ,mensaje = "Registro exitoso", content = contenido)
开发者ID:ivanortegaalba,项目名称:DAI_2014-2015,代码行数:33,代码来源:persistencia-mongo-10.py


示例12: parse_action_impl

    def parse_action_impl(self, action, table, db):
        if action == 'set_user':
            username = self.qs_dict.get('username')
            if not username:
                set_status_code(web, 400)
                return result_template('''Illegal parameters: no "username"''')
            username = ''.join(username)

            data = web.data()
            # TODO

            if debug:
                web.debug('DB action=set_user, username=%s' % username)
            username = db.set_user(username, {'data': data})
            return username
        if action == 'get_user':
            username = self.qs_dict.get('username')
            if not username:
                set_status_code(web, 400)
                return result_template('''Illegal parameters: no "username"''')
            username = ''.join(username)

            if debug:
                web.debug('DB action=get_user, username=%s' % username)
            data = db.load_user(username)
            return username_data_template(username, data['data'], data['_id'])
开发者ID:lao5-team,项目名称:dashen6-server,代码行数:26,代码来源:query_parser.py


示例13: parse_action

    def parse_action(self, web, db):

        web.header('Content-Type', 'text/json')
        cookie = web.cookies()
        login, user, token = check_login(cookie)
        if not login:
            set_status_code(web, 401)
            return not_login_template()

        qs = web.ctx.env.get('QUERY_STRING')
        if not qs:
            set_status_code(web, 400)
            return result_template('''No parameters''')
        self.qs_dict = urlparse.parse_qs(qs)

        action = self.qs_dict.get('action')
        table = self.qs_dict.get('table')
        if not action or not table:
            set_status_code(web, 400)
            return result_template('''Illegal parameters: no "action" nor "table"''')
        action = ''.join(action)
        table = ''.join(table)
        if action in self.actions:
            try:
                return self.parse_action_impl(action, table, db)
            except Exception, e:
                web.debug(str(e))
                set_status_code(web, 500)
                return exception_template(e)
开发者ID:lao5-team,项目名称:dashen6-server,代码行数:29,代码来源:query_parser.py


示例14: POST

	def POST(self):
		x = web.input(myfile={})
		name = web.debug(x['myfile'].filename) # This is the filename
		web.debug(x['myfile'].value) # This is the file contents
		web.debug(x['myfile'].file.read()) # Or use a filline object
		form = web.input(contents=None)
		return render.uploaded(name = str(name), contents = form.contents) 		
开发者ID:Micaiah-Chang,项目名称:LPTHW,代码行数:7,代码来源:app.py


示例15: POST

 def POST(self, cmd):
     if cmd == 'total':
         pts = MongoUtil.fetchPage('columbia',{}, 0, 1)
         return pts.count()
     if cmd == 'upload':
         params = web.data();
         #passTime = params.passTime
         #ua = params.ua
         jsonData = simplejson.loads(params)
         web.debug("passTime:%r", jsonData)
         ctime = jsonData.get('time')
         MongoUtil.save('columbia', jsonData)
         if ctime:
             histGram = MongoUtil.fetch('histgram', {})
             if not histGram:
                 histGram = {}
             
             val = histGram.get(ctime)
             if val:
                 ++val
                 histGram[ctime] = val
             else:
                 histGram[ctime] = 1
             MongoUtil.update('histgram', histGram)
             total = 1
             beating = 1
             for tm in histGram:
                 if tm > ctime:
                     total += histGram.get(tm)
                     beating += histGram.get(tm)
                 else:
                     total  += histGram.get(tm)
             
             return 100 * beating/total
开发者ID:tianwalker2012,项目名称:handpa,代码行数:34,代码来源:clumbia.py


示例16: load_config

def load_config(filename=None):
    """Load configuration from file and merge with defaults.
    
       The 'filename' of the configuration file.
    """
    # load config file
    if filename and filename.startswith('~'):
        filename = os.path.expanduser(filename)
    if not filename or not os.path.exists(filename):
        filename = os.path.expanduser(default_config_filename)
        if not os.path.exists(filename):
            return
    
    if config.debug:
        web.debug("Loading configuration from: " + filename)
    
    # skips if the file is empty
    contents = file(filename).read()
    if len(contents):
        input = json.load(file(filename))
    else:
        return

    # merge config
    for topic in input:
        if topic not in config:
            continue
        if not isinstance(input[topic], dict):
            config[topic] = input[topic]
            continue
        for key in input[topic]:
            config[topic][key] = input[topic][key]
开发者ID:robes,项目名称:adapt-policy-service,代码行数:32,代码来源:config.py


示例17: varify_params

 def varify_params(self, requestId, begin_ts, end_ts, media_type, channel_uuid):
     if begin_ts >= end_ts:
         err_info = {"requestId":requestId, "error": {"code": 400, "message": "begin_ts is larger or equal to end_ts"}}
         web.debug("error: %s"% str(err_info))
         err_info = simplejson.dumps(err_info)
         raise web.webapi._status_code("400 Bad Request", web.webapi.BadRequest, "begin_ts is larger or equal to end_ts"), err_info
     
     ltime = int(time.time())
     if begin_ts < ltime - self.max_reservetime * 3600:
         err_info = {"requestId":requestId, "error": {"code": 400, "message": "begin_ts is not in reserved time"}}
         web.debug("error: %s"% str(err_info))
         err_info = simplejson.dumps(err_info)
         raise web.webapi._status_code("400 Bad Request", web.webapi.BadRequest, "begin_ts is not in reserved time"), err_info
     
     if media_type.lower() not in ('video', 'screenshot'):
     
         err_info = {"requestId":requestId, "error": {"code": 400, "message": "type is error"}}
         web.debug("error: %s"% str(err_info))
         err_info = simplejson.dumps(err_info)
         raise web.webapi._status_code("400 Bad Request", web.webapi.BadRequest, "type is error"), err_info
     
     if channel_uuid is None:
         web.debug(" channel uuid is null")
         err_info = {"requestId":requestId, "error": {"code": 400, "message": "the channel uuid is not error"}}
         web.debug("error: %s"% str(err_info))
         err_info = simplejson.dumps(err_info)
         raise web.webapi._status_code("400 Bad Request", web.webapi.BadRequest, "the channel uuid is not using"), err_info
开发者ID:szqh97,项目名称:test,代码行数:27,代码来源:fake_screenshot_service.py


示例18: POST

 def POST(self):
     global oss, MAX_UPLOAD_SIZE
     print web.ctx.env.get('CONTENT_TYPE')
     if web.ctx.env.get('CONTENT_LENGTH') > MAX_UPLOAD_SIZE :
         return {"errno": 102,
                 "errmsg": "File size cannot more than 15M." }
     x = web.input(myfile={})
     if not x.has_key('myfile') or x['myfile'] == '':
         return {"errno": 100,
                 "errmsg": "Invalid upload !"}
     try:
         web.debug(x['myfile'].filename) # This is the filename
         content = x['myfile'].value
         dc = bencode.bdecode(content)
         binfo = bencode.bencode(dc['info'])
         infohash = sha1(binfo).hexdigest()
         sio = StringIO.StringIO()
         gz = gzip.GzipFile(fileobj=sio, mode="wb")
         gz.write(content)
         gz.close()
         gzcontent = sio.getvalue()
         if oss:
             res = oss.put_object_from_string(bucket = "test2312", 
                     object = "%s.torrent" % infohash.upper(),
                     input_content = gzcontent,
                     headers = {"Content-Encoding": "gzip"})
         return {"gzcontent" : res.status,
                 "infohash": infohash}
     except:
         return {"errno": 101,
                 "errmsg": "Unknow error, sorry :("}
开发者ID:progresstudy,项目名称:bcache,代码行数:31,代码来源:wsgi.py


示例19: getTrendingTopics

def getTrendingTopics( placeId=1 ):
	"""
	Request a list of top Twitter trends worldwide
	"""
	returnValue = []
	requestUrl = 'https://api.twitter.com/1.1/trends/place.json'

	#Authorize app
	accessToken = authorize()

	if accessToken is not None:

		# set header with access token
		headers = {
		'Authorization' : 'Bearer '+ accessToken 
		}
		# fill in required location field to fetch worldwide trending topics
		params = { 'id': placeId }
		try:
			# make request, and populate list to be returned with name and urls
			response = requests.get( requestUrl, params=params, headers=headers )
			responseJson = response.json()
			if 'trends' in responseJson[ 0 ]:
				for trend in responseJson[ 0 ][ 'trends' ]:
					returnValue.append( { 'name': trend[ 'name' ], 'url': trend[ 'url' ] } )
			return returnValue
		except HTTPError as e:
			web.debug( e )
	else:
		web.debug( "Failed to get Twitter values" )
		return "Error while fetching topics"
开发者ID:tony56a,项目名称:hapless-walnut,代码行数:31,代码来源:webrequest.py


示例20: addNewUser

def addNewUser():
	# Add the user to the user database
	dbPath = "/srv/www/trackr.scottjackson.org/db/users.db"
	if DEBUG:
		dbPath = "/Users/scottjacksonx/Documents/dev/git/trackr/db/users.db"
	
	userID = 0
	conn = sqlite3.connect(dbPath)
	c = conn.cursor()
	c.execute("select MAX(id) from users")
	for row in c:
		userID = int(row[0])
		userID += 1
		web.debug("userID = " + str(userID))
		thirtyOneDays = 2678400
		web.setcookie("userid", userID, thirtyOneDays)
	c.execute("insert into users values(?)", (userID,))
	conn.commit()
	c.close()
	
	# Add a new table in the likes database for the user's likes
	dbPath = "/srv/www/trackr.scottjackson.org/db/likes.db"
	if DEBUG:
		dbPath = "/Users/scottjacksonx/Documents/dev/git/trackr/db/likes.db"
	conn = sqlite3.connect(dbPath)
	c = conn.cursor()
	values = (userID,)
	c.execute("create table ? (id INTEGER PRIMARY KEY)", values)
	conn.commit()
	c.close()
开发者ID:scottjacksonx,项目名称:Trackr,代码行数:30,代码来源:code.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python web.decode函数代码示例发布时间:2022-05-26
下一篇:
Python web.database函数代码示例发布时间: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