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


Python user.User类代码示例

本文整理汇总了Python中point.core.user.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, field=None, value=None):
        if isinstance(field, (int, long)):
            User.__init__(self, field)
            return
        if field and value:
            User.__init__(self, field, value)
            return

        sess = Session()

        self.id = sess['id']
        self.login = sess['login']
        self.type = 'user'

        self.accounts = []
        self.accounts_add = []
        self.accounts_del = []
        self.profile = {}
        self.profile_upd = {}
        self.info = {}
        self.info_upd = {}
        self.password = None

        self.redis = RedisPool(settings.storage_socket)

        if self.id:
            self._get_avatar()
开发者ID:isqua-test,项目名称:point-www,代码行数:27,代码来源:user.py

示例2: usercss

def usercss(login):
    try:
        u = User('login', login)
    except UserNotFound:
        raise NotFound
    css = u.get_profile('www.usercss')
    return Response(css, mimetype='text/css')
开发者ID:kainwinterheart,项目名称:point-www,代码行数:7,代码来源:users.py

示例3: info

def info(login):
    try:
        user = User('login', login)
    except UserNotFound:
        raise NotFound

    try:
        data = users.info(user)
    except SubscribeError:
        raise Forbidden
    data['login'] = login
    try:
        data['created'] = timestamp(data['created'])
    except (KeyError, AttributeError):
        pass
    try:
        data['birthdate'] = timestamp(data['birthdate'])
    except (KeyError, AttributeError):
        pass
    if env.user.id:
        data['subscribed'] = user.check_subscriber(env.user)
        data['rec_sub'] = user.check_rec_subscriber(env.user)
        if not data['subscribed']:
            data['bl'] = env.user.check_blacklist(user)
            if not data['bl']:
                data['wl'] = env.user.check_blacklist(user)
    return Response(json.dumps(data), mimetype='application/json')
开发者ID:kainwinterheart,项目名称:point-www,代码行数:27,代码来源:users.py

示例4: info

def info(login):
    try:
        user = User('login', login)
    except UserNotFound:
        raise NotFound

    try:
        data = users.info(user)
    except SubscribeError:
        raise Forbidden
    data['id'] = user.id
    data['login'] = user.login
    try:
        data['created'] = data['created']
    except (KeyError, AttributeError):
        pass
    try:
        data['birthdate'] = data['birthdate']
    except (KeyError, AttributeError):
        pass
    if env.user.id:
        data['subscribed'] = user.check_subscriber(env.user)
        data['rec_sub'] = user.check_rec_subscriber(env.user)
        if not data['subscribed']:
            data['bl'] = env.user.check_blacklist(user)
            if not data['bl']:
                data['wl'] = env.user.check_blacklist(user)
    return data
开发者ID:Raegdan,项目名称:point-www,代码行数:28,代码来源:users.py

示例5: authenticate_ulogin

    def authenticate_ulogin(self, network, uid):
        res = db.fetchone("SELECT id FROM users.ulogin_accounts "
                          "WHERE network=%s AND uid=%s;", [network, uid])
        if not res:
            raise NotAuthorized

        User.__init__(self, int(res[0]))
        self.authenticate()
开发者ID:isqua-test,项目名称:point-www,代码行数:8,代码来源:user.py

示例6: unsubscribe_rec

def unsubscribe_rec(login):
    if isinstance(login, User):
        user = login
    else:
        user = User('login', login)

    if not user.check_subscriber(env.user):
        return False

    user.del_rec_subscriber(env.user)
开发者ID:postman0,项目名称:point-core,代码行数:10,代码来源:users.py

示例7: info

def info(user):
    """Get user info
    """
    if isinstance(user, (str, unicode)):
        user = User('login', user)

    if env.user.id != user.id and user.get_profile('private') \
            and not user.check_whitelist(env.user):
        raise SubscribeError

    return user.get_info()
开发者ID:postman0,项目名称:point-core,代码行数:11,代码来源:users.py

示例8: reset_password

def reset_password(code, password):
    redis = RedisPool(settings.storage_socket)
    key = 'reset-password:%s' % code
    print key
    id = redis.get(key)
    if not id:
        raise UserNotFound
    try:
        user = User(int(id))
    except ValueError:
        raise UserNotFound
    user.set_password(password)
    user.save()
    redis.delete(key)
    return user
开发者ID:postman0,项目名称:point-core,代码行数:15,代码来源:users.py

示例9: recipients

 def recipients(self):
     res = db.fetchall(
         "SELECT u.id, u.login FROM posts.recipients r "
         "JOIN users.logins u ON u.id=r.user_id "
         "WHERE r.post_id=%s;",
         [unb26(self.id)],
     )
     return [User.from_data(r[0], r[1]) for r in res]
开发者ID:ap-Codkelden,项目名称:point-core,代码行数:8,代码来源:post.py

示例10: get_info

    def get_info(self, param=None):
        if self.id or self.info or self.info_upd:
            return User.get_info(self, param)

        if param:
            return None

        return {}
开发者ID:isqua-test,项目名称:point-core,代码行数:8,代码来源:__init__.py

示例11: recommended_users

 def recommended_users(self):
     res = db.fetchall(
         "SELECT u.id, u.login FROM posts.recommendations r "
         "JOIN users.logins u ON u.id=r.user_id "
         "WHERE post_id=%s AND comment_id=0;",
         [unb26(self.id)],
     )
     return [User.from_data(r[0], r[1]) for r in res]
开发者ID:ap-Codkelden,项目名称:point-core,代码行数:8,代码来源:post.py

示例12: subscribe_rec

def subscribe_rec(login):
    """Subscribe to user's recommendations
       returns True if subscribed, and False if subscription request is sent
    """
    if isinstance(login, User):
        user = login
    else:
        user = User('login', login)

    if env.user.id == user.id:
        raise SubscribeError

    if not user.check_subscriber(env.user):
        return subscribe(user)

    user.add_rec_subscriber(env.user)
    return True
开发者ID:postman0,项目名称:point-core,代码行数:17,代码来源:users.py

示例13: save

    def save(self):
        is_new = not self.id

        if is_new and not self._url:
            raise InvalidFeedUrl("Cannot save feed without URL")

        if not self.login:
            self.login = self._generate_login()

        User.save(self)

        if is_new:
            db.perform("INSERT INTO users.feeds (id, url) VALUES (%s, %s);",
                       [self.id, self._url])

            self.fetch()

            for p in self.posts():
                p.save()
            self.update_task()
开发者ID:isqua-test,项目名称:point-core,代码行数:20,代码来源:__init__.py

示例14: subscribe

def subscribe(login):
    """Subscribe to user
       returns True if subscribed, and False if subscription request is sent
    """
    if isinstance(login, User):
        user = login
    else:
        user = User('login', login)

    if env.user.id == user.id:
        raise SubscribeError

    if user.add_subscription_request(env.user):
        publish('sub', {'to':user.id, 'a':'sub', 'from':env.user.login})
        log.info('sub %d %s' % (user.id, env.user.login))
        return True

    else:
        publish('sub', {'to':user.id, 'a':'req', 'from':env.user.login})
        log.info('sub request %d %s' % (user.id, env.user.login))
        return False
开发者ID:postman0,项目名称:point-core,代码行数:21,代码来源:users.py

示例15: avatar

def avatar(login, size):
    """To avoid code duplication, parameter ``login`` can be interpreted 
    as a number if it is user id, and as a string if it is user login"""
    size = int(size) if size else 40
    try:
        if login and login.isdigit():
            user = User(int(login))
        else:
            user = User('login', login)
        avatar = user.get_info('avatar')
    except UserNotFound:
        avatar = None

    if avatar:
        path = '%s%s/%s/%s' % \
               (env.request.protocol, settings.avatars_root, size, avatar)
    else:
        path = '%s%s/av%s.png' % \
               (env.request.protocol, settings.avatars_root, size)

    return Response(redirect=path)
开发者ID:kainwinterheart,项目名称:point-www,代码行数:21,代码来源:users.py


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