本文整理汇总了Python中oasis.lib.Users2.find方法的典型用法代码示例。如果您正苦于以下问题:Python Users2.find方法的具体用法?Python Users2.find怎么用?Python Users2.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Users2
的用法示例。
在下文中一共展示了Users2.find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_usersearch
# 需要导入模块: from oasis.lib import Users2 [as 别名]
# 或者: from oasis.lib.Users2 import find [as 别名]
def setup_usersearch():
""" Show a page allowing the admin search for users, or create new ones"""
user_id = session['user_id']
if not check_perm(user_id, -1, "useradmin"):
flash("You do not have User Administration access.")
return redirect(url_for('setup_top'))
users = []
nonefound = False
if request.method == "POST":
if 'usersearch_name' in request.form:
needle = request.form['usersearch_name']
if len(needle) < 2:
flash("Search term too short, please try something longer")
else:
uids = Users2.find(needle)
users = [Users2.get_user(uid) for uid in uids]
if len(users) == 0:
nonefound = True
else:
users.sort(key=lambda x: x['uname'])
return render_template(
'setup_usersearch.html',
users=users,
nonefound=nonefound
)