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