本文整理汇总了Python中db.models.User.drops方法的典型用法代码示例。如果您正苦于以下问题:Python User.drops方法的具体用法?Python User.drops怎么用?Python User.drops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.models.User
的用法示例。
在下文中一共展示了User.drops方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find
# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import drops [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
示例2: authenticate
# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import drops [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)