本文整理汇总了Python中bespin.database.User.find_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_by_email方法的具体用法?Python User.find_by_email怎么用?Python User.find_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bespin.database.User
的用法示例。
在下文中一共展示了User.find_by_email方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lost
# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_by_email [as 别名]
def lost(request, response):
"""Generates lost password email messages"""
email = request.POST.get('email')
username = request.POST.get('username')
if username:
user = User.find_user(username)
if not user:
raise BadRequest("Unknown user: " + username)
verify_code = _get_password_verify_code(user)
change_url = c.base_url + "?pwchange=%s;%s" % (username, verify_code)
context = dict(username=username, base_url=c.base_url,
change_url=change_url)
send_email_template(user.email, "Requested password change for " + c.base_url,
"lost_password.txt", context)
elif email:
users = User.find_by_email(email)
context = dict(email=email,
usernames=[dict(username=user.username) for user in users],
base_url=c.base_url)
send_email_template(email, "Your username for " + c.base_url,
"lost_username.txt", context)
else:
raise BadRequest("Username or email is required.")
return response()
示例2: test_create_new_user
# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_by_email [as 别名]
def test_create_new_user():
s = _get_session(True)
num_users = s.query(User).count()
assert num_users == 0
user = User.create_user("BillBixby", "hulkrulez", "[email protected]")
assert len(user.uuid) == 36
num_users = s.query(User).count()
assert num_users == 1
users = User.find_by_email("[email protected]")
assert users[0].username == "BillBixby"
示例3: test_create_new_user
# 需要导入模块: from bespin.database import User [as 别名]
# 或者: from bespin.database.User import find_by_email [as 别名]
def test_create_new_user():
s = _get_session(True)
num_users = s.query(User).count()
assert num_users == 0
user = User.create_user("BillBixby", "hulkrulez", "[email protected]")
assert len(user.uuid) == 36
num_users = s.query(User).count()
assert num_users == 1
result = s.connection().execute(EventLog.select()).fetchall()
assert len(result) == 1
users = User.find_by_email("[email protected]")
assert users[0].username == "BillBixby"
assert len(users) == 1
user = User.find_user("[email protected]")
assert user == users[0]