本文整理汇总了Python中utils.utils.decode_params函数的典型用法代码示例。如果您正苦于以下问题:Python decode_params函数的具体用法?Python decode_params怎么用?Python decode_params使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode_params函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
def post(self):
params = utils.decode_params(self.request)
res = {}
res[KEY.IID_LIST] = db.get_neighbor(params)
res[KEY.STATUS] = STATUS.OK
self.write(res)
示例2: post
def post(self):
params = {}
resp = {KEY.STATUS: 500}
params = utils.decode_params(self.request)
if KEY.EVENT_ID not in params:
self.write(json_encode(resp))
return
'''trans the term's type'''
params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
supporter_ids = db.list_support_relation(params)
print supporter_ids
if supporter_ids is not None:
supporter_info = []
for item in supporter_ids:
user_info = db.get_user_information({KEY.ID: item})
if user_info is not None:
user = {}
user[KEY.ID] = user_info[KEY.ID]
user[KEY.NICKNAME] = user_info[KEY.NICKNAME]
user[KEY.NAME] = user_info[KEY.NAME]
user[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
user[KEY.REPUTATION] = user_info[KEY.REPUTATION]
user[KEY.LOCATION] = user_info[KEY.LOCATION]
user[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]
user[KEY.GENDER] = user_info[KEY.GENDER]
supporter_info.append(user)
resp[KEY.STATUS] = 200
resp[KEY.INFO] = supporter_info
self.write(json_encode(resp))
示例3: post
def post(self):
params = utils.decode_params(self.request)
print "From login handler: "
print params
resp = {}
if KEY.SALT not in params:
salt = db.get_salt(params)
if salt is None:
resp[KEY.STATUS] = STATUS.ERROR
else:
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.SALT] = salt
#resp[KEY.STATUS] = STATUS.OK
else:
user_id = db.validate_password(params)
if user_id > 0:
resp[KEY.STATUS] = STATUS.OK
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.ID] = user_id
else:
resp[KEY.STATUS] = STATUS.ERROR
print "From login handler: resp:"
print resp
self.write(json_encode(resp))
示例4: post
def post(self):
params = utils.decode_params(self.request)
result = baidulbs.update_location(params, KEY.EVENT)
resp = {}
resp[KEY.STATUS] = STATUS.OK
self.write(json_encode(resp))
示例5: post
def post(self):
params = utils.decode_params(self.request)
resp = {}
if KEY.SALT not in params:
salt = db.get_salt(params)
if salt is None:
resp[KEY.STATUS] = 500
else:
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.SALT] = salt
user_id = db.validate_password(params)
if user_id > 0:
resp[KEY.STATUS] = 200
resp[KEY.ID] = user_id
self.set_secure_cookie(KEY.USER_NAME, resp[KEY.ACCOUNT])
self.set_secure_cookie(KEY.ID, str(resp[KEY.ID]))
else:
resp[KEY.STATUS] = 300
else:
user_id = db.validate_password(params)
if user_id > 0:
resp[KEY.STATUS] = 200
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.ID] = user_id
self.set_secure_cookie(KEY.USER_NAME, resp[KEY.ACCOUNT])
self.set_secure_cookie(KEY.ID, str(resp[KEY.ID]))
else:
resp[KEY.STATUS] = 300
self.write(json_encode(resp))
示例6: post
def post(self):
params = {}
resp = {KEY.STATUS: 500}
params = utils.decode_params(self.request)
if KEY.ID not in params or KEY.EVENT_ID not in params or KEY.USER_ID not in params or KEY.VALUE not in params:
self.write(json_encode(resp))
return
'''trans the term's type'''
params[KEY.ID] = int(params[KEY.ID])
params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
params[KEY.USER_ID] = int(params[KEY.USER_ID])
params[KEY.VALUE] = float(params[KEY.VALUE])
flag = db.evaluate_user(params)
if flag:
'''we can import here, use some algorithm to incease the helper's reputation'''
user = db.get_user_information({KEY.ID: params[KEY.USER_ID]})
if user is not None:
reputation = user[KEY.REPUTATION]
params[KEY.VALUE] = reputation*(1 - VALUE.RATE) + VALUE.RATE*params[KEY.VALUE]
if db.update_user({KEY.ID: params[KEY.USER_ID], KEY.REPUTATION: params[KEY.VALUE]}):
resp[KEY.STATUS] = 200
self.write(json_encode(resp))
示例7: post
def post(self):
params = utils.decode_params(self.request)
resp = {}
answer_id = db.add_answer(params)
if answer_id == -1:
resp[KEY.STATUS] = STATUS.ERROR
else:
resp[KEY.STATUS] = STATUS.OK
event_info = db.get_event_information({KEY.EVENT_ID: params[KEY.EVENT_ID]})
user_info = db.get_user_information({KEY.ID: event_info[KEY.LAUNCHER_ID]})
user_info = utils.trans_unicode_to_utf(user_info)
event_info = utils.trans_unicode_to_utf(event_info)
is_like = 0
if db.is_user_like_event({KEY.ID: event_info[KEY.LAUNCHER_ID], KEY.EVENT_ID: params[KEY.EVENT_ID]}):
is_like = 1
custom = {KEY.EVENT_ID: params[KEY.EVENT_ID], KEY.NICKNAME: user_info[KEY.NICKNAME], KEY.TIME: event_info[KEY.TIME], KEY.TITLE: event_info[KEY.TITLE], \
KEY.CONTENT: event_info[KEY.CONTENT], KEY.LOVE_COIN: event_info[KEY.LOVE_COIN], KEY.FOLLOW_NUMBER: event_info[KEY.FOLLOW_NUMBER],\
KEY.SUPPORT_NUMBER: event_info[KEY.SUPPORT_NUMBER], KEY.IS_LIKE: is_like}
custom['message-type'] = 5
mess = sendHelp.buildMessage(type=1, title=title, content=content, style=style, action=action, custom=custom)
print sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
'''and send the tongyou message'''
mess = sendHelp.buildMessage(custom=custom)
print sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
resp[KEY.ANSWER_ID] = answer_id
self.write(json_encode(resp))
示例8: post
def post(self):
params = utils.decode_params(self.request)
resp = {}
if KEY.SALT not in params:
salt = db.get_salt(params)
if salt is None:
resp[KEY.STATUS] = STATUS.ERROR
else:
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.STATUS] = STATUS.OK
resp[KEY.SALT] = salt
else:
user_id = db.validate_password(params)
print user_id
if user_id > 0:
resp[KEY.STATUS] = STATUS.OK
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.ID] = user_id
if not utils.is_App(self.request):
self.set_secure_cookie("username", resp[KEY.ACCOUNT])
self.set_secure_cookie("id", str(resp[KEY.ID]))
else:
resp[KEY.STATUS] = STATUS.ERROR
self.write(json_encode(resp))
示例9: post
def post(self):
params = {}
resp = {KEY.STATUS: 500}
params = utils.decode_params(self.request)
if KEY.ID not in params or KEY.EVENT_ID not in params:
self.write(json_encode(resp))
return
'''trans the term's type'''
params[KEY.ID] = int(params[KEY.ID])
params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
event_info = db.get_event_information(params)
if event_info is not None:
if event_info[KEY.LAUNCHER_ID] == params[KEY.ID]:
resp[KEY.STATUS] = 200
params[KEY.STATE] = 1
if not db.update_event(params):
resp[KEY.STATUS] = 500
else:
'''send a notification to notice the user. all supporters'''
supporter_ids = db.list_support_relation({KEY.EVENT_ID: params[KEY.EVENT_ID]})
if supporter_ids is not None:
resp[KEY.STATUS] = 200
for item in supporter_ids:
user_info = db.get_user_information({KEY.ID: item})
user_info = utils.trans_unicode_to_utf(user_info)
mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 1, 3))
sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
mess = sendHelp.buildMessage(custom={'message-type': 2})
sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
self.write(json_encode(resp))
示例10: post
def post(self):
params = {}
resp = {KEY.STATUS: 500}
params = utils.decode_params(self.request)
if KEY.ID not in params or KEY.LAUNCHER_ID not in params or KEY.TYPE not in params or KEY.EVENT_ID not in params:
self.write(json_encode(resp))
return
'''trans the term's type'''
params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
params[KEY.ID] = int(params[KEY.ID])
params[KEY.LAUNCHER_ID] = int(params[KEY.LAUNCHER_ID])
params[KEY.TYPE] = int(params[KEY.TYPE])
flag = db.remove_support_relation(params)
if flag:
'''when the event is help or emergence, it is necessary to notify the users'''
user_info = db.get_user_information({KEY.ID: params[KEY.LAUNCHER_ID]})
user_info = utils.trans_unicode_to_utf(user_info)
if user_info is not None:
if params[KEY.TYPE] == 2:
mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 1, 3))
sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
if params[KEY.TYPE] == 1:
mess = sendHelp.buildMessage(type=1, title=title, content=content, style=xinge.Style(0, 0, 0, 0, 6))
sendHelp.sendEhelp(header + user_info[KEY.NICKNAME], mess)
resp[KEY.STATUS] = 200
self.write(json_encode(resp))
示例11: post
def post(self):
params = utils.decode_params(self.request)
resp = {}
result = True
if KEY.OPERATION in params and params[KEY.OPERATION] == 0:
result = db.remove_static_relation(params)
elif KEY.OPERATION in params and params[KEY.OPERATION] == 1:
result = db.add_static_relation(params)
'''send the tongtou message to tell the user'''
user_info = db.get_user_information({KEY.ID: params[KEY.ID]})
user_acc = db.get_user_information({KEY.ID: params[KEY.USER_ID]})
user_info = utils.trans_unicode_to_utf(user_info)
user_acc = utils.trans_unicode_to_utf(user_acc)
mess_package = {KEY.USER_ID: user_info[KEY.ID], KEY.NICKNAME: user_info[KEY.NICKNAME],\
KEY.REALNAME: user_info[KEY.NAME], KEY.LOCATION: user_info[KEY.LOCATION], KEY.OCCUPATION: user_info[KEY.OCCUPATION]}
mess_package[KEY.TYPE] = params[KEY.TYPE]
mess_package['message-type'] = 4
if KEY.CONTENT in params:
mess_package[KEY.CONTENT] = params[KEY.CONTENT]
mess = sendHelp.buildMessage(custom=mess_package)
print sendHelp.sendEhelp(header + user_acc[KEY.NICKNAME], mess)
else:
result = False
if result:
resp[KEY.STATUS] = STATUS.OK
else:
resp[KEY.STATUS] = STATUS.ERROR
self.write(json_encode(resp))
示例12: post
def post(self):
params = {}
resp = {}
params = utils.decode_params(self.request)
if KEY.ACCOUNT in params and KEY.PASSWORD in params and KEY.PHONE in params:
if Session.Session.exists(params):
'''if user not exists, return true'''
if db.check_user_exist(params):
user_id = db.add_account(params)
if user_id > 0:
'''set the user phone number'''
db.update_user({KEY.ID: user_id, KEY.PHONE: params[KEY.PHONE]})
resp[KEY.STATUS] = 200
resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
resp[KEY.ID] = user_id
resp[KEY.SALT] = db.get_salt(params)
resp[KEY.CHAT_TOKEN] = db.get_chat_token(params)
bank_account_id = db.create_loving_bank(resp, 20, 0)
else:
resp[KEY.STATUS] = 250
else:
resp[KEY.STATUS] = 260
else:
resp[KEY.STATUS] = 270
else:
resp[KEY.STATUS] = 300
self.write(json_encode(resp))
示例13: post
def post(self):
params = {}
resp = {KEY.STATUS: 500}
params = utils.decode_params(self.request)
if KEY.EVENT_ID not in params:
self.write(json_encode(resp))
return
'''trans the term's type'''
params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
event_info = db.get_event_information(params)
if event_info is not None:
resp[KEY.STATUS] = 200
resp[KEY.LAUNCHER_ID] = event_info[KEY.LAUNCHER_ID]
resp[KEY.TIME] = event_info[KEY.TIME]
resp[KEY.TYPE] = int(event_info[KEY.TYPE])
resp[KEY.SUPPORT_NUMBER] = event_info[KEY.SUPPORT_NUMBER]
resp[KEY.DEMAND_NUMBER] = event_info[KEY.DEMAND_NUMBER]
resp[KEY.LONGITUDE] = event_info[KEY.LONGITUDE]
resp[KEY.LATITUDE] = event_info[KEY.LATITUDE]
resp[KEY.LAUNCHER_NAME] = event_info[KEY.LAUNCHER]
user = db.get_user_information({KEY.ID: resp[KEY.LAUNCHER_ID]})
if user is not None:
resp[KEY.CONTACT] = user[KEY.PHONE]
'''if this event is help'''
if resp[KEY.TYPE] == 1:
resp[KEY.TITLE] = event_info[KEY.TITLE]
resp[KEY.CONTENT] = event_info[KEY.CONTENT]
resp[KEY.LOVE_COIN] = int(event_info[KEY.LOVE_COIN])
self.write(json_encode(resp))
示例14: post
def post(self):
params = {}
resp = {KEY.STATUS: 500}
params = utils.decode_params(self.request)
if KEY.EVENT_ID not in params:
self.write(json_encode(resp))
return
'''trans the term's type'''
params[KEY.EVENT_ID] = int(params[KEY.EVENT_ID])
launcher_info = db.get_event_information(params)
if launcher_info is not None:
user_info = db.get_user_information({KEY.ID: launcher_info[KEY.LAUNCHER_ID]})
if user_info is not None:
resp[KEY.STATUS] = 200
resp[KEY.ID] = user_info[KEY.ID]
resp[KEY.NICKNAME] = user_info[KEY.NICKNAME]
resp[KEY.NAME] = user_info[KEY.NAME]
resp[KEY.AGE] = user_info[KEY.AGE]
resp[KEY.GENDER] = user_info[KEY.GENDER]
resp[KEY.PHONE] = user_info[KEY.PHONE]
resp[KEY.OCCUPATION] = user_info[KEY.OCCUPATION]
resp[KEY.REPUTATION] = user_info[KEY.REPUTATION]
resp[KEY.LOCATION] = user_info[KEY.LOCATION]
resp[KEY.IS_VERIFY] = user_info[KEY.IS_VERIFY]
self.write(json_encode(resp))
示例15: post
def post(self):
resp = {}
resp[KEY.STATUS] = 500
params = {}
#对当前请求对象的参数解析,得到当前请求对象里面的参数
params = utils.decode_params(self.request)
if KEY.EMAIL in params and KEY.ACCOUNT in params:
userInfo = {}
userInfo = db.get_user_information_by_email(params)
if userInfo is not None:
if KEY.NICKNAME in userInfo and userInfo[KEY.NICKNAME] == params[KEY.ACCOUNT]:
#获得验证码
idencode = ''.join(random.sample(string.ascii_letters, 4))
#emailt = email.PlainEmail()
userEmail = params[KEY.EMAIL].replace('%40', '@')
#if emailt.sendPlainEmail(params[KEY.EMAIL], "找回密码", "您的验证码为:" + idencode) == 200:
if sendEmail.sendEmail([userEmail], "找回密码", "您的验证码为:" + idencode) == 200:
md5_encode = hashlib.md5()
md5_encode.update(userInfo[KEY.NICKNAME] + idencode)
idencode = md5_encode.hexdigest()
resp[KEY.STATUS] = 200
resp["secret"] = idencode
self.write(json_encode(resp))