本文整理汇总了Python中post.Post.post_db_key方法的典型用法代码示例。如果您正苦于以下问题:Python Post.post_db_key方法的具体用法?Python Post.post_db_key怎么用?Python Post.post_db_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.post_db_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_posts
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import post_db_key [as 别名]
def get_posts(self):
user = users.get_current_user()
post_list = []
post_query = Post.query(ancestor = Post.post_db_key()).order(-Post.created)
post_list = post_query.fetch(10)
if user and len(post_list) == 0:
post = Post(parent = Post.post_db_key(), author = user, content = 'Hallo Leute! Hier ist mal eine allererste Version des Kollaborationswerkzeugs, ich nenne das erst mal einfach nur <b>Toolbox</b>. In dieser ersten Version kann man allerdings noch nichts machen, ich arbeite dran ;-) Schaut euch die Seite zwei, drei mal am Tag an, ich will zügig Ergebnisse liefern.')
post.put()
post_query = Post.query(ancestor = Post.post_db_key()).order(-Post.created)
post_list = post_query.fetch(10)
return post_list
示例2: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import post_db_key [as 别名]
def post(self):
user = users.get_current_user()
if user:
post = Post(parent = Post.post_db_key(), author = user, content = self.request.get("content"))
post.put()
self.redirect('/')
示例3: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import post_db_key [as 别名]
def get(self, urlString = None):
if urlString:
user = users.get_current_user()
if user:
rev_key = ndb.Key(urlsafe=urlString)
last_post = rev_key.get()
post_query = Post.query(Post.created < last_post.created, ancestor = Post.post_db_key()).order(-Post.created)
post_list = post_query.fetch(10)
if len(post_list) > 0:
urlString = post_list[len(post_list) - 1].key.urlsafe()
posts = []
for post in post_list:
dict = { 'nickname': post.author.nickname(), 'content': post.content, 'created': post.created.strftime("%d.%m.%Y %H:%M:%S") }
posts.append(dict)
post_dict = { 'urlString': urlString, 'posts': posts }
self.response.write(json.dumps(post_dict))
else:
self.response.write('{ "message": "please log in" }')