本文整理汇总了Python中user.models.User.by_username方法的典型用法代码示例。如果您正苦于以下问题:Python User.by_username方法的具体用法?Python User.by_username怎么用?Python User.by_username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.models.User
的用法示例。
在下文中一共展示了User.by_username方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import by_username [as 别名]
def login(username=None):
'''
Does all the login stuff
The whole login system is called from this
'''
# Check if banned first
b = User.chkbnid(User.host())
# cuserid(NULL));
logger.debug("BANNED %d", b)
if username:
username = username.lower()
user = User.by_username(username)
if user:
authenticate(user)
return user
# Get the user name
user = None
while not user:
user = input_username(username)
username = ''
if user.id:
# Password checking
authenticate(user)
else:
register(user)
cls()
return user
示例2: show
# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import by_username [as 别名]
def show(username):
user = User.by_username(username)
if user is None:
print("\nNo user registered in that name\n\n")
else:
print("\n\nUser Data For {}\n".format(user.username))
print("Name: {}\nPassword: {}\n".format(user.username, user.password))
return user
示例3: input_username
# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import by_username [as 别名]
def input_username(username, prompt="By what name shall I call you?\n*\t"):
if not username:
username = input(prompt)[:15]
# Check for legality of names
try:
user = User(username)
except AssertionError as e:
print(e)
return None
user = User.by_username(username)
if user:
return user
# If he/she doesnt exist
answer = input("Did I get the name right {}? ".format(username)).lower()
if answer[0] == 'y':
user = User(username=username)
return user