本文整理汇总了Python中models.Post.asyncQuery方法的典型用法代码示例。如果您正苦于以下问题:Python Post.asyncQuery方法的具体用法?Python Post.asyncQuery怎么用?Python Post.asyncQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.asyncQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import asyncQuery [as 别名]
def get(self, title):
post = yield Post.asyncQuery(title=title).first()
self.form.create_time.data = \
self.UTC2BeiJingTime(datetime.datetime.utcnow())
if post:
self.form.post_id.data = post.id
self.form.title.data = post.title
self.form.content.data = post.content
self.form.markdown.data = post.markdown
self.form.create_time.data = \
self.UTC2BeiJingTime(post.create_time)
self.form.category.data = post.category.name
self.form.tags.data = ','.join(post.tags)
self.render("compose.html", form=self.form)
示例2: post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import asyncQuery [as 别名]
def post(self, title):
post = yield Post.asyncQuery(title=title).first()
if not post:
raise tornado.web.HTTPError(404)
if self.form.validate():
comment = Comment()
comment.create_time = datetime.datetime.utcnow()
comment.author_name = self.form.author_name.data
comment.author_email = self.form.author_email.data
comment.author_url = self.form.author_url.data
# Direct use user post data is unsafe,
# so we convert `org_markdown_text` in the back-end
comment.content = markdown2.markdown(self.form.content.data)
post.comments.append(comment)
yield post.save()
self.flash("评论提交成功~")
return self.redirect("{path}{id}".format(
path=self.request.path, id="#comment"))
self.render("post.html", post=post, form=self.form)