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


Python User.games方法代码示例

本文整理汇总了Python中db.models.User.games方法的典型用法代码示例。如果您正苦于以下问题:Python User.games方法的具体用法?Python User.games怎么用?Python User.games使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.models.User的用法示例。


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

示例1: find

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import games [as 别名]
    def find(id):
        from db.models import DiscuzMember, User
        from sqlalchemy.orm import joinedload

        s = current_session()

        try:
            uid = int(id)
            uid = uid if uid < 500000 else None
        except ValueError:
            uid = None

        q = s.query(DiscuzMember).options(joinedload('ucmember'))
        if uid:
            dz_member = q.filter(DiscuzMember.uid == uid).first()
        else:
            dz_member = q.filter(DiscuzMember.email == id).first()
            dz_member = dz_member or q.filter(DiscuzMember.username == id).first()

        if not dz_member:
            return None

        uid = dz_member.uid
        user = s.query(User).filter(User.id == uid).first()
        if not user:
            user = User()
            s.add(user)

        user.dz_member = dz_member

        # sync
        user.games    = dz_member.member_count.games
        user.drops    = dz_member.member_count.drops
        user.jiecao   = dz_member.member_count.jiecao

        return user
开发者ID:,项目名称:,代码行数:38,代码来源:

示例2: authenticate

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import games [as 别名]
    def authenticate(cls, username, password):
        from db.models import User

        try:
            uid = int(username)
        except:
            return None

        user = cls.find(username)
        if not user:
            s = current_session()

            user = User()
            user.id = uid
            user.username = str(username)
            user.email = str(username)
            user.credits = 998
            user.games = 1
            user.drops = 0

            s.add(user)
            s.flush()

        return cls()._fill_account(user)
开发者ID:,项目名称:,代码行数:26,代码来源:


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