本文整理汇总了Python中post.Post.key方法的典型用法代码示例。如果您正苦于以下问题:Python Post.key方法的具体用法?Python Post.key怎么用?Python Post.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import key [as 别名]
def post(self):
if not self.user:
self.redirect('/blog')
subject = self.request.get('subject')
content = self.request.get('content')
created_by = self.user.name
if subject and content:
p = Post(parent = blog_key(), subject = subject, content = content, created_by = created_by)
p.put()
self.redirect('/blog/%s' % str(p.key().id()))
else:
error = "subject and content, please!"
self.render("newpost.html", subject=subject, content=content, error=error)
示例2: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import key [as 别名]
def post(self):
if not self.user:
self.redirect('/blog')
subject = self.request.get('subject')
content = self.request.get('content')
created_by = self.user.user_id
display_name = self.user.name
if subject and content:
p = Post(parent = blog_key(), subject = subject, content = content,
created_by = created_by, display_name = display_name)
p.put()
#rerun the query and update the cache
Post.get_posts(True)
self.redirect('/blog/%s' % str(p.key().id()))
else:
error = "subject and content, please!"
self.render("newpost.html", subject=subject, content=content, error=error)
示例3: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import key [as 别名]
def post(self):
"""
Creates new post and redirect to new post page.
"""
if not self.user:
return self.redirect('/blog')
subject = self.request.get('subject')
content = self.request.get('content')
if subject and content:
p = Post(parent=blog_key(), user_id=self.user.key().id(),
subject=subject, content=content)
p.put()
self.redirect('/blog/%s' % str(p.key().id()))
else:
error = 'Empty subject and/or content!'
self.render('new-post.html', subject=subject,
content=content, error=error)
示例4: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import key [as 别名]
def post(self):
self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
postid = self.request.get("postid")
post = self.request.get("post")
user = self.request.get("user")
key = self.request.get("key")
value = self.request.get("value")
query = Post.all()
query.filter("postid = ", postid)
postResult = query.fetch(1000)
post = Post(postid=postid, post=post)
if len(postResult) > 0:
post = postResult[0]
else:
post.put()
tag = Tag(userid=user, postkey=post.key(), tag_key=key, tag_value=value)
tag.put()
query = Relation.all()
query.filter("user = ", user)
followers = query.fetch(1000)
for f in followers:
tag.addToStream(f.follower)
self.response.out.write("Tagged post " + postid + " with " + user + ":" +
key + "=" + value)