本文整理汇总了Python中model.User.User.modify_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.modify_user方法的具体用法?Python User.modify_user怎么用?Python User.modify_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User.User
的用法示例。
在下文中一共展示了User.modify_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RemoveHandler
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import modify_user [as 别名]
class RemoveHandler(tornado.web.RequestHandler):
def initialize(self, mysql_handler, LOG):
self.mysql_handler = mysql_handler
self.LOG = LOG
self.user = User(mysql_handler, LOG)
self.device = Device(mysql_handler, LOG)
self.favorite = Favorite(mysql_handler, LOG)
self.rsp_handler = CommResponse()
return
def post(self):
self.LOG.debug('this is %s' % self.__class__.__name__)
try:
request_json = json.loads(self.request.body)
user_phone = request_json['user_phone']
user_login_mobile_uuid = request_json['user_login_mobile_uuid']
collection_type = request_json['collection_type']
collection_name = request_json['collection_name']
except Exception as e:
self.LOG.error('parameters error.')
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21001', None)
self.write(self.rsp_msg)
return
if not self.user.check_login_status(user_phone, user_login_mobile_uuid):
self.LOG.error('user [%s] not login.' % user_phone)
self.mysql_handler.rollback_db()
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21006', None)
self.write(self.rsp_msg)
return
(ret, num) = self.favorite.remove_collection(user_phone, collection_name, collection_type)
if not ret:
self.LOG.error('delete collection from mysql failed.')
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21999', None)
self.mysql_handler.rollback_db()
self.write(self.rsp_msg)
return
if num:
modify_info = {
'collected': 'collected - 1'
}
if collection_type == 'user':
self.user.modify_user(collection_name, modify_info)
elif collection_type == 'device':
self.device.modify_device(collection_name, modify_info)
self.rsp_msg = self.rsp_handler.generate_rsp_msg('200', None)
self.mysql_handler.commit_db()
self.write(self.rsp_msg)
return
示例2: ModifyHandler
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import modify_user [as 别名]
class ModifyHandler(UserHandler):
def initialize(self, mysql_handler, LOG):
super(UserHandler, self).initialize()
self.mysql_handler = mysql_handler
self.LOG = LOG
self.user = User(mysql_handler, LOG)
self.rsp_handler = CommResponse()
return
def post(self):
self.LOG.debug('this is %s' % self.__class__.__name__)
try:
request_json = json.loads(self.request.body)
user_phone = request_json['user_phone']
user_login_mobile_uuid = request_json['user_login_mobile_uuid']
except Exception as e:
self.LOG.error('parameters error.')
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21001', None)
self.write(self.rsp_msg)
return
if not self.user.check_login_status(user_phone, user_login_mobile_uuid):
self.LOG.error('user [%s] not login.' % user_phone)
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21006', None)
self.mysql_handler.rollback_db()
self.write(self.rsp_msg)
return
user_info = dict(request_json)
del user_info['user_phone']
if not self.user.modify_user(user_phone, user_info):
self.LOG.error('update user [%s] info into mysql failed.' % user_phone)
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21999', None)
self.mysql_handler.rollback_db()
self.write(self.rsp_msg)
return
self.mysql_handler.commit_db()
self.LOG.info('user [%s] modify info successful.' % user_phone)
self.rsp_msg = self.rsp_handler.generate_rsp_msg('200', None)
self.write(self.rsp_msg)
return
示例3: LoginHandler
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import modify_user [as 别名]
class LoginHandler(UserHandler):
def initialize(self, service_config, mysql_handler, redis_handler, LOG):
super(UserHandler, self).initialize()
self.mysql_handler = mysql_handler
self.redis_handler = redis_handler
self.LOG = LOG
self.user = User(mysql_handler, LOG)
self.picture = Picture(mysql_handler, LOG)
self.rsp_handler = CommResponse()
self.show_account = service_config['show_account']
return
def verify_security_code(self, user_phone, security_code):
key = 'security:%s' % user_phone
field = 'security_code'
save_code = self.redis_handler.redis_conn.hget(key, field)
if security_code.upper() == save_code:
self.redis_handler.redis_conn.delete(key)
self.LOG.info('this user [%s] sms verify successful.' % user_phone)
return True
else:
self.LOG.error('this user [%s] sms verify failed.' % user_phone)
return False
def post(self):
self.LOG.debug('this is %s' % self.__class__.__name__)
try:
request_json = json.loads(self.request.body)
self.LOG.info(request_json)
user_phone = request_json['user_phone']
user_phone_mno = request_json['user_phone_mno']
security_code = request_json['security_code']
user_login_mobile_uuid = request_json['user_login_mobile_uuid']
except Exception as e:
self.LOG.error('parameters error.')
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21001', None)
self.write(self.rsp_msg)
return
if user_phone != self.show_account:
if not self.verify_security_code(user_phone, security_code):
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21002', None)
self.write(self.rsp_msg)
return
user_info = self.get_self_info(user_phone)
if user_info:
if user_info['login_status'] == 'login' and user_info['user_login_mobile_uuid'] != user_login_mobile_uuid:
modify_info = {
'user_login_mobile_uuid': user_login_mobile_uuid
}
else: #elif user_info['login_status'] != 'login':
modify_info = {
'login_status': 'login',
'user_login_mobile_uuid': user_login_mobile_uuid
}
self.user.modify_user(user_phone, modify_info)
user_info['user_login_mobile_uuid'] = user_login_mobile_uuid
rsp_data = {
'rsp_data': {
'user': user_info
}
}
self.rsp_msg = self.rsp_handler.generate_rsp_msg('200', rsp_data)
self.mysql_handler.commit_db()
self.write(self.rsp_msg)
return
ret, user_id = self.user.add_user(user_phone, user_phone_mno, user_login_mobile_uuid)
if not ret:
self.rsp_msg = self.rsp_handler.generate_rsp_msg('21999', None)
self.mysql_handler.rollback_db()
self.write(self.rsp_msg)
return
user_info = self.get_self_info(user_phone)
rsp_data = {
'rsp_data': {
'user': user_info
}
}
self.rsp_msg = self.rsp_handler.generate_rsp_msg('200', rsp_data)
self.LOG.info('user [%s] login successful.' % user_phone)
self.LOG.debug(self.rsp_msg)
self.mysql_handler.commit_db()
self.write(self.rsp_msg)
return