本文整理汇总了Python中model.User.find_by_username方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_by_username方法的具体用法?Python User.find_by_username怎么用?Python User.find_by_username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.find_by_username方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: following
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_by_username [as 别名]
def following(name):
user = User.find_by_username(name)
is_logged=user_is_logged()
if user:
return bottle.template('following',followees= user.followees,page="followee",logged=is_logged)
return bottle.HTTPError(code=404)
示例2: user_page
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_by_username [as 别名]
def user_page(name):
is_following,is_logged= False,user_is_logged()
user= User.find_by_username(name)
if user:
counts = user.followees_count,user.followers_count,user.tweet_count
logged_user= logged_in_user()
himself = logged_user.username == name
if logged_user:
is_following = logged_user.following(user)
return bottle.template('user',posts=user.posts(),counts=counts,page='user',username=user.username,logged=is_logged,is_following=is_following,himself=himself)
else:
return bottle.HTTPError(code=404)
示例3: login
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_by_username [as 别名]
def login():
if 'name' in bottle.request.POST and 'password' in bottle.request.POST:
name = bottle.request.POST['name']
password = bottle.request.POST['password']
user=User.find_by_username(name)
if user and user.password == hashlib.md5(settings.SALT+password).hexdigest():
sess = Session(bottle.request,bottle.response)
sess['id']=user.id
sess.save()
bottle.redirect('/home')
return bottle.template('login',page='login',error_login=True,error_signup=False,logged=False)
示例4: unfollowpost
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_by_username [as 别名]
def unfollowpost(user,name):
user_to_unfollow = User.find_by_username(name)
if user_to_unfollow:
user.stop_following(user_to_unfollow)
bottle.redirect('/%s' % name)
示例5: followpost
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import find_by_username [as 别名]
def followpost(user,name):
user_to_follow = User.find_by_username(name)
if user_to_follow:
user.follow(user_to_follow)
bottle.redirect('/%s' % name)