当前位置: 首页>>代码示例>>Python>>正文


Python User.load方法代码示例

本文整理汇总了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()
开发者ID:pannellr,项目名称:3132GroupProject,代码行数:27,代码来源:usercontroller.py

示例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})
开发者ID:BakanovKirill,项目名称:kitten-net,代码行数:22,代码来源:__init__.py

示例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})
开发者ID:nskrypnik,项目名称:kitten-net,代码行数:22,代码来源:__init__.py

示例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")
开发者ID:BakanovKirill,项目名称:kitten-net,代码行数:24,代码来源:test_actions.py

示例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
开发者ID:BakanovKirill,项目名称:kitten-net,代码行数:6,代码来源:test_users.py


注:本文中的users.User.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。