本文整理汇总了Python中users.User.load方法的典型用法代码示例。如果您正苦于以下问题:Python User.load方法的具体用法?Python User.load怎么用?Python User.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserController
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import load [as 别名]
class UserController(MasterController):
_user = None
def __init__(self, args=None):
self._user = User()
super(UserController, self).__init__()
def login(self, args):
password = self._user.return_pw(args['user_name'])
if password['password'] == args['password']:
self._user.load(args['user_name'])
self._session.setCookie(self._user)
print self._session._cookie
self._user.attach(PostController)
self._user.notify()
def logout(self, args):
self._session.clearCookie()
print self._session._cookie
self._user.attach(PostController)
self._user.notify()
示例2: auth
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import load [as 别名]
def auth(connection, email, password=None, token=None):
user = User.load(email)
if not user:
params = {'result': 'Fail', 'errormsg': 'No such user'}
connection.response({'cmd': 'auth', 'params': params})
return
auth_succesful = False
if token and token == user.token:
auth_succesful = True
if password and hashlib.md5(password).hexdigest() == user.password:
auth_succesful = True
if auth_succesful:
user.update_token()
params = {'result': 'Ok', 'token': user.token}
connection.response({'cmd': 'auth', 'params': params})
connection.authenticate(user)
else:
params = {'result': 'Fail', 'errormsg': 'Authentication failed'}
connection.response({'cmd': 'auth', 'params': params})
示例3: auth
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import load [as 别名]
def auth(connection, email, password=None, token=None):
user = User.load(email)
if not user:
params = {"result": "Fail", "errormsg": "No such user"}
connection.response({"cmd": "auth", "params": params})
return
auth_succesful = False
if token and token == user.token:
auth_succesful = True
if password and hashlib.md5(password).hexdigest() == user.password:
auth_succesful = True
if auth_succesful:
user.update_token()
params = {"result": "Ok", "token": user.token}
connection.response({"cmd": "auth", "params": params})
connection.authenticate(user)
else:
params = {"result": "Fail", "errormsg": "Authentication failed"}
connection.response({"cmd": "auth", "params": params})
示例4: test_search
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import load [as 别名]
def test_search(self):
actions.register(connection, email='[email protected]', password='bogdan19861')
actions.auth(connection, "[email protected]", password='bogdan19861', token=None)
dumb_socket2 = DumbSocket()
connection2 = Connection(dumb_socket2)
actions.register(connection2, email='[email protected]', password='bogdan1986')
actions.auth(connection2, "[email protected]", password='bogdan1986', token=None)
dumb_socket3 = DumbSocket()
connection3 = Connection(dumb_socket3)
actions.register(connection3, email='[email protected]', password='bogdan21986')
actions.auth(connection2, "[email protected]", password='bogdan21986', token=None)
actions.add_friend(connection, email="[email protected]")
actions.add_friend(connection, email="[email protected]")
user = User.load('[email protected]')
print user.get_friends()
actions.search(connection, need="kitten")
示例5: test_load_user
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import load [as 别名]
def test_load_user(self):
user = User.load("[email protected]")
self.assertEqual(user.email, "[email protected]")
print user.id