本文整理汇总了Python中models.Author.get方法的典型用法代码示例。如果您正苦于以下问题:Python Author.get方法的具体用法?Python Author.get怎么用?Python Author.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Author
的用法示例。
在下文中一共展示了Author.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_auth_user
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import get [as 别名]
def get_auth_user():
userid = request.get_cookie("user", secret=SECRET)
try:
user = Author.get(id=userid)
except Author.DoesNotExist:
return None
return user
示例2: admin_index
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import get [as 别名]
def admin_index():
post_count = Post.select().count()
comm_count = Comment.select().count()
tag_count = Tag.select().count()
cate_count = Category.select().count()
author = Author.get(id=1)
posts = Post.select().paginate(1, 5)
comments = Comment.select().order_by(('published', 'desc')).paginate(1, 5)
return template('admin/index.html', posts=posts, comments=comments,
post_count=post_count, comm_count=comm_count,
tag_count=tag_count, cate_count=cate_count, author=author)
示例3: post_admin_login
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import get [as 别名]
def post_admin_login():
email = request.forms.get('email').decode('utf-8')
password = request.forms.get('password').decode('utf-8')
try:
user = Author.get(email=email)
except Author.DoesNotExist:
redirect('/auth/login')
enpass = user.password
if is_password(password, enpass):
response.set_cookie("user", user.id, secret=SECRET, path="/",
max_age=30 * 24 * 60 * 60)
redirect('/admin')
else:
redirect('/auth/login')
示例4: admin_changepass
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import get [as 别名]
def admin_changepass():
oldpass = request.forms.get('oldpass').decode('utf-8')
pass1 = request.forms.get('newpass').decode('utf-8')
pass2 = request.forms.get('newpass2').decode('utf-8')
try:
user = Author.get(id=1)
except Author.DoesNotExist:
redirect('/admin')
enpass = user.password
if (is_password(oldpass, enpass) and pass1 == pass2):
newpass = hexpassword(pass1)
Author.update(password=newpass).where(id=1).execute()
redirect('/admin')
redirect('/admin/settings')
示例5: admin_settings
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import get [as 别名]
def admin_settings():
author = Author.get(id=1)
return template('admin/settings.html', author=author)