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


Python BlogPost.get_by_id方法代码示例

本文整理汇总了Python中blog.models.BlogPost.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python BlogPost.get_by_id方法的具体用法?Python BlogPost.get_by_id怎么用?Python BlogPost.get_by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blog.models.BlogPost的用法示例。


在下文中一共展示了BlogPost.get_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: decorate

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import get_by_id [as 别名]
 def decorate(self, post_id=None):
     post = None
     if post_id:
         post = BlogPost.get_by_id(int(post_id))
         if not post:
             raise NotFound
     return fun(self, post)
开发者ID:calvinchengx,项目名称:O-Kay-Blog-wih-Kay-0.10.0,代码行数:9,代码来源:admin.py

示例2: post_delete

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import get_by_id [as 别名]
def post_delete(request, post_id):
	post = BlogPost.get_by_id(int(post_id))
	user = users.get_current_user()
	if request.method == "POST" and post.author == user.email():
		post.key.delete()
		return redirect("home")
	else:
		return redirect("forbidden")
开发者ID:ramuta,项目名称:simple-blog,代码行数:10,代码来源:views.py

示例3: generate_resource

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import get_by_id [as 别名]
 def generate_resource(cls, post, resource):
     from blog.models import BlogPost
     if not post:
         post = BlogPost.get_by_id(resource)
     else:
         assert resource == post.key().id()
     template_vals = {
         'post': post,
         'config': config,
     }
     template_name = "blog/themes/%s/post.html" % config.theme
     rendered = utils.render_template(template_name, template_vals)
     StaticContent.set(post.path, rendered, config.html_mime_type)
开发者ID:calvinchengx,项目名称:O-Kay-Blog-wih-Kay-0.10.0,代码行数:15,代码来源:generators.py

示例4: post_edit

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import get_by_id [as 别名]
def post_edit(request, post_id):
	post = BlogPost.get_by_id(int(post_id))
	user = users.get_current_user()
	if request.method == "GET" and post.author == user.email():
		form = BlogPostForm({"title": post.title, "content": post.content})
		params = {"form": form, "post": post}
		return blog_render(request, "post_edit.html", params)
	elif request.method == "POST" and post.author == user.email():
		form = BlogPostForm(request.POST)

		if form.is_valid():
			BlogPost.edit(post_id=int(post_id),
			              title=form.cleaned_data["title"],
			              content=form.cleaned_data["content"])
		else:
			params = {"form": form}
			return blog_render(request, "post_add.html", params)

		return redirect("home")
	else:
		return redirect("forbidden")
开发者ID:ramuta,项目名称:simple-blog,代码行数:23,代码来源:views.py

示例5: post_view

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import get_by_id [as 别名]
def post_view(request, post_id):
	post = BlogPost.get_by_id(int(post_id))
	params = {"post": post}
	return blog_render(request, "post_view.html", params)
开发者ID:ramuta,项目名称:simple-blog,代码行数:6,代码来源:views.py

示例6: get_blog_post

# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import get_by_id [as 别名]
def get_blog_post(blog_post_id):
    return BlogPost.get_by_id(int(blog_post_id))
开发者ID:tb123,项目名称:tushar.bhatia.io,代码行数:4,代码来源:utils.py


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