本文整理汇总了Python中models.user.User.get_by_uid方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_uid方法的具体用法?Python User.get_by_uid怎么用?Python User.get_by_uid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.get_by_uid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_global_vars
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_uid [as 别名]
def init_global_vars():
g.page = request.args.get('page', type=int, default=0)
g.start = request.args.get('start', type=int, default=g.page * 20)
g.limit = request.args.get('limit', type=int, default=20)
if request.path == '/user/login_from_openid/' or request.path.startswith('/ajax'):
return
if 'uid' not in session:
abort(401)
g.user = User.get_by_uid(session['uid'])
示例2: grant_project
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_uid [as 别名]
def grant_project(uid):
user = User.get_by_uid(uid)
if not user:
return {'reason': '用户不存在'}, 404
name = request.form.get('project', '')
p = Project.get_by_name(name)
if not p:
return {'reason': '项目不存在'}, 404
user.grant_project(name)
log = OPLog.create(g.user.id, OPLOG_ACTION.grant_project)
log.project_name = name
log.acceptor = user.uid
示例3: set_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_uid [as 别名]
def set_user():
u = User.get_by_uid(request.form['uid'])
if u is None:
raise ValueError('no such user')
group = request.form['group']
if group:
u.set_group(group)
flags = request.form.getlist('privs')
privilege = reduce(lambda x, y: x | y, [getattr(USER_ROLE, p.lower(), 0) for p in flags], 0)
u.set_privilege(privilege)
log = OPLog.create(g.user.id, OPLOG_ACTION.grant_privilege)
log.privilege = privilege
log.acceptor = u.uid
示例4: user_detail
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_uid [as 别名]
def user_detail(uid):
user = User.get_by_uid(uid)
if not user:
abort(404)
return render_template('/settings/user_detail.html', user=user)