本文整理汇总了Python中post.Post.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.by_id方法的具体用法?Python Post.by_id怎么用?Python Post.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import by_id [as 别名]
def get(self, post_id):
post = Post.by_id(post_id)
comments = Comment.comments_by_post_id(post.key().id())
if not post:
self.redirect('/blog')
return
if self.user:
self.render("permalink.html", post = post, username = self.user.name,comments=comments,user_id=self.user.key().id())
else:
self.render("permalink.html", post = post,comments=comments)
示例2: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import by_id [as 别名]
def post(self,post_id):
if not self.user:
self.redirect('/blog/%s' % post_id)
subject = self.request.get('subject')
content = self.request.get('content')
user_id = self.user.key().id()
last_modified = datetime.datetime.now()
post = Post.by_id(post_id)
if post and post.created_by == user_id:
Post.update(post_id,subject,content,last_modified)
self.redirect('/blog/%s' % post_id)