本文整理汇总了Python中utils.dotdict.DotDict.has_key方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.has_key方法的具体用法?Python DotDict.has_key怎么用?Python DotDict.has_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.dotdict.DotDict
的用法示例。
在下文中一共展示了DotDict.has_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import has_key [as 别名]
def put(self):
"""Update the parameters of terminal.
"""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
tid = data.get('tid', None)
# check tid whether exist in request and update current_user
self.check_tid(tid)
logging.info("[UWEB] Terminal request: %s, uid: %s, tid: %s",
data, self.current_user.uid, self.current_user.tid)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
terminal = QueryHelper.get_available_terminal(
self.current_user.tid, self.db)
if not terminal:
status = ErrorCode.LOGIN_AGAIN
logging.error("[UWEB] The terminal with tid: %s does not exist,"
" redirect to login.html",
self.current_user.tid)
self.write_ret(status)
return
user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
if not user:
status = ErrorCode.LOGIN_AGAIN
logging.error("[UWEB] The user with uid: %s does not exist,"
" redirect to login.html",
self.current_user.uid)
self.write_ret(status)
return
# sql injection
if data.has_key('corp_cnum') and not check_cnum(data.corp_cnum):
status = ErrorCode.ILLEGAL_CNUM
self.write_ret(status)
return
# NOTE: deprecated
if data.has_key('white_list'):
white_list = ":".join(data.white_list)
if not check_sql_injection(white_list):
status = ErrorCode.ILLEGAL_WHITELIST
self.write_ret(status)
return
self.update_terminal_db(data)
# NOTE: wspush to client
if status == ErrorCode.SUCCESS:
WSPushHelper.pushS7(tid, self.db, self.redis)
self.write_ret(status)
except Exception as e:
logging.exception("[UWEB] uid:%s, tid:%s update terminal info failed. Exception: %s",
self.current_user.uid, self.current_user.tid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
示例2: put
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import has_key [as 别名]
def put(self):
"""Modify profile of current operator.
"""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
logging.info("[UWEB] Operator profile request: %s, oid: %s, tid: %s",
data, self.current_user.oid, self.current_user.tid)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
#if data.has_key('email') and not check_sql_injection(data.email):
if data.has_key('email') and len(data.email)>50:
status = ErrorCode.ILLEGAL_EMAIL
self.write_ret(status,
message=u'联系人邮箱的最大长度是50个字符!')
return
update_operator(data, self.current_user.oid, self.db, self.redis)
self.write_ret(status)
except Exception as e:
logging.exception("[UWEB] Update operator profile failed. oid:%s, Exception: %s",
self.current_user.oid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
示例3: post
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import has_key [as 别名]
def post(self):
"""Add a terminal.
"""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
logging.info("[UWEB] Corp add terminal request: %s, cid: %s",
data, self.current_user.cid)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
if data.has_key('cnum') and not check_cnum(data.cnum):
status = ErrorCode.ILLEGAL_CNUM
self.write_ret(status)
return
# 1 year
begintime = int(time.time())
now_ = datetime.datetime.now()
endtime = now_ + relativedelta(years=1)
endtime = int(time.mktime(endtime.timetuple()))
# 1: add terminal
#umobile = data.umobile if data.umobile else self.current_user.cid
if data.umobile:
umobile = data.umobile
else:
corp = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
umobile = corp.get('c_mobile', '')
terminal = QueryHelper.get_terminal_by_tmobile(data.tmobile, self.db)
if terminal:
if terminal.service_status == UWEB.SERVICE_STATUS.TO_BE_UNBIND:
delete_terminal(terminal.tid, self.db, self.redis)
else:
logging.error(
"[UWEB] mobile: %s already existed.", data.tmobile)
status = ErrorCode.TERMINAL_ORDERED
self.write_ret(status)
return
vibl = data.get("vibl")
use_scene = get_use_scene_by_vibl(vibl)
biz_type = data.get('biz_type', UWEB.BIZ_TYPE.YDWS)
tid = data.tmobile
terminal_info = dict(tid=tid,
group_id=data.group_id,
tmobile=data.tmobile,
owner_mobile=umobile,
mannual_status=UWEB.DEFEND_STATUS.YES,
begintime=begintime,
endtime=4733481600,
offline_time=begintime,
cnum=data.cnum,
icon_type=data.icon_type,
login_permit=data.login_permit,
push_status=data.push_status,
vibl=data.vibl,
use_scene=use_scene,
biz_type=biz_type,
speed_limit=data.speed_limit,
stop_interval=data.stop_interval,
service_status=UWEB.SERVICE_STATUS.ON)
if int(biz_type) == UWEB.BIZ_TYPE.YDWS:
# 0. check tmobile is whitelist or not
white_list = check_zs_phone(data.tmobile, self.db)
if not white_list:
logging.error("[UWEB] mobile: %s is not whitelist.", data.tmobile)
status = ErrorCode.MOBILE_NOT_ORDERED
message = ErrorCode.ERROR_MESSAGE[status] % data.tmobile
self.write_ret(status, message=message)
return
# 4: send message to terminal
register_sms = SMSCode.SMS_REGISTER % (umobile, data.tmobile)
ret = SMSHelper.send_to_terminal(data.tmobile, register_sms)
else:
tid = get_tid_from_mobile_ydwq(data.tmobile)
activation_code = QueryHelper.get_activation_code(self.db)
terminal_info['tid'] = tid
terminal_info['activation_code'] = activation_code
terminal_info['service_status'] = UWEB.SERVICE_STATUS.TO_BE_ACTIVATED
register_sms = SMSCode.SMS_REGISTER_YDWQ % (ConfHelper.UWEB_CONF.url_out, activation_code)
ret = SMSHelper.send(data.tmobile, register_sms)
add_terminal(terminal_info, self.db, self.redis)
# record the add action
bind_info = dict(tid=data.tmobile,
tmobile=data.tmobile,
umobile=umobile,
group_id=data.group_id,
cid=self.current_user.cid,
add_time=int(time.time()))
record_add_action(bind_info, self.db)
#.........这里部分代码省略.........