当前位置: 首页>>代码示例>>Python>>正文


Python Post.get_by_id方法代码示例

本文整理汇总了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)    
开发者ID:BlowBlood,项目名称:blowblood,代码行数:10,代码来源:blog.py

示例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]))
开发者ID:jamespullar,项目名称:cs253,代码行数:11,代码来源:main.py

示例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'))
开发者ID:Algy,项目名称:micro-blog,代码行数:11,代码来源:views.py

示例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)
开发者ID:Algy,项目名称:micro-blog,代码行数:11,代码来源:views.py

示例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)
开发者ID:Algy,项目名称:micro-blog,代码行数:13,代码来源:views.py

示例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('/')
开发者ID:BlowBlood,项目名称:blowblood,代码行数:17,代码来源:blog.py

示例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)
开发者ID:dreampuf,项目名称:bana,代码行数:20,代码来源:admin_views.py

示例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();
开发者ID:straightDeveloper,项目名称:sec-blog,代码行数:7,代码来源:blog.py


注:本文中的model.Post.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。