本文整理汇总了Python中model.Post.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.get_by_id方法的具体用法?Python Post.get_by_id怎么用?Python Post.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.get_by_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def get(self,PostID):
post = Post.get_by_id(int(PostID))
tags_commas = post.tags_commas
template_values = {
'post': post,
'tags_commas': tags_commas,
}
self.generate('../templates/edit.html', template_values)
示例2: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def get(self, *post_id):
self.response.headers['Content-Type'] = 'application/json; charset=UTF-8'
if post_id:
post = Post.get_by_id(int(post_id[0]))
self.write(json.dumps(post.to_dict()))
else:
posts_query = Post.all().order('-created')
posts = posts_query.fetch(10)
self.write(json.dumps([p.to_dict() for p in posts]))
示例3: delete_post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def delete_post(id):
"""Método responsável em remover um post do blog."""
post = Post.get_by_id(id)
if post:
post.delete()
flash("Post foi removido com sucesso.")
else:
flash("Erro ao tentar remover post.")
return redirect(url_for('get'))
示例4: form_update_post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def form_update_post(id):
"""Método responsável em criar form update para o blog."""
try:
form = PostForm( Post.get_by_id(id) )
title = 'Update - %s' % form.title.data.strip()
action = '%i/update' % int(id)
return render_template('form_post.html', form=form, title=title, action=action)
except:
abort(404)
示例5: update_post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def update_post(id):
post = Post.get_by_id(id)
form = PostForm()
title = 'Update - %s' % form.title.data
action = '%i/update' % int(id)
if form.validate_on_submit():
form.model = post
form.save()
flash('Post atualizado.')
return redirect(url_for('get'))
return render_template('form_post.html', form=form, title=title, action=action)
示例6: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def post(self,PostID):
post= Post.get_by_id(int(PostID))
if(post is not None):
post.clear_tags()
post.clear_archive()
post.clear_category()
comments = post.comment_set
for comment in comments:
comment.delete()
post.delete()
util.flushRecentComment()
util.flushCategoryLists()
util.flushArchiveLists()
util.flushTagLists()
return self.redirect('/')
示例7: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def get(self, post_id):
p = Post.get_by_id(int(post_id)) if post_id.isdigit() else None
if not p:
self.redirect(config.BLOG_ADMIN_PATH + "post/")
return
context = {"page_name": u"编辑文章",
"page_title": u"编辑文章",
"all_category": Category.get_all(),
"post.title": p.title,
"post.category": p.category.key().name(),
"post.url": p.url,
"post.tags": ",".join(p.tags),
"post.keyword": ",".join(p.keyword),
"post.content": p.content,
"post.format": p.format }
self.render("admin_post_editor.html", context)
示例8: postDelete
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_by_id [as 别名]
def postDelete(ID):
if ID:
myPost = Post.get_by_id(ID);
if myPost:
myPost.key.delete();