本文整理汇总了Python中models.Post.find_by_path方法的典型用法代码示例。如果您正苦于以下问题:Python Post.find_by_path方法的具体用法?Python Post.find_by_path怎么用?Python Post.find_by_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.find_by_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_path [as 别名]
def get(self, path):
if not self.user:
self.redirect('/login')
post_id = self.request.get('id')
if post_id and post_id.isdigit():
post = Post.find_by_id(post_id=int(post_id), path=path)
if not post:
self.abort(404)
else:
post = Post.find_by_path(path=path).get()
self.render("edit_post.html", path=path, post=post)
示例2: post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_path [as 别名]
def post(self, path):
if not self.user:
self.error(403)
return
author = self.user.username
title = self.request.get('post_title')
content = self.request.get('post_content')
# look for old version first
old_post = Post.find_by_path(path).get()
if old_post:
old_post.version = 0
old_post.put()
if not (old_post or content or title):
return
# TODO: problem with versioning if title is changed
elif not old_post or old_post.content != content or old_post.title != title:
post = Post(parent=Post.parent_key(path), author=author, title=title, content=content)
post.put()
self.redirect(path)