本文整理匯總了Python中dao.UserDao.get_user_by_token方法的典型用法代碼示例。如果您正苦於以下問題:Python UserDao.get_user_by_token方法的具體用法?Python UserDao.get_user_by_token怎麽用?Python UserDao.get_user_by_token使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dao.UserDao
的用法示例。
在下文中一共展示了UserDao.get_user_by_token方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: resp
# 需要導入模塊: from dao import UserDao [as 別名]
# 或者: from dao.UserDao import get_user_by_token [as 別名]
def resp(token, did):
user = UserDao.get_user_by_token(token)
if not user: return RESPONSE.WRONG_TOKEN
devices = DeviceDao.get_devices_by_user(user)
for device in devices:
if device['did'] == did:
#TODO 需要進行一些數據清理工作
return RESPONSE.SUCCESS
return RESPONSE.WRONG_DID
示例2: update
# 需要導入模塊: from dao import UserDao [as 別名]
# 或者: from dao.UserDao import get_user_by_token [as 別名]
def update(token,did,loc_info):
user = UserDao.get_user_by_token(token)
if not user: return {'status':0, 'desc':'wrong token'}
device_loc = LocCollection.find_one({'did':did})
if device_loc:
device_loc['loc_info'].append(loc_info)
else:
device_loc = {
'did':did,
'loc_info': loc_info
}
LocCollection.update({'did':did}, device_loc, upsert=True)
return {'status':1}
示例3: pull
# 需要導入模塊: from dao import UserDao [as 別名]
# 或者: from dao.UserDao import get_user_by_token [as 別名]
def pull(token, did):
user = UserDao.get_user_by_token(token)
if not user: return RESPONSE.WRONG_TOKEN
devices = DeviceDao.get_devices_by_user(user)
for device in devices:
if device['did'] == did:
#TODO 需要將具體的信息返回回去
RESPONSE.PULL_SUCCESS['data'] = device['pull_info']
device['pull_info']=[]
UserCollection.update({'token':user['token']},user)
return RESPONSE.PULL_SUCCESS
return RESPONSE.WRONG_DID
示例4: initial
# 需要導入模塊: from dao import UserDao [as 別名]
# 或者: from dao.UserDao import get_user_by_token [as 別名]
def initial(token,phone,did,cid,imei):
user = UserDao.get_user_by_token(token)
if not user: return RESPONSE.WRONG_TOKEN
devices = DeviceDao.get_devices_by_user(user)
for device in devices:
if device['phone'] == phone:
device['did'] = did
device['cid'] = cid
device['imei'] = imei
UserCollection.update({'tid':user['tid']},user)
#TODO 需要增加client對初始化配置信息
RESPONSE.INITIAL_SUCCESS['initial'] = {}
return RESPONSE.INITIAL_SUCCESS
return RESPONSE.WRONG_PHONE
示例5: test_get_user_by_token
# 需要導入模塊: from dao import UserDao [as 別名]
# 或者: from dao.UserDao import get_user_by_token [as 別名]
def test_get_user_by_token():
user = UserDao.get_user_by_email(email)
user2 = UserDao.get_user_by_token(user['token'])
assert user2['email'] == email