本文整理汇总了Python中post.Post.query方法的典型用法代码示例。如果您正苦于以下问题:Python Post.query方法的具体用法?Python Post.query怎么用?Python Post.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_posts
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import query [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: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import query [as 别名]
def get(self):
posts = Post.query(Post.isPosted == True).order(-Post.postedDate)
template = JINJA_ENVIRONMENT.get_template('templates/home.html')
template_values = {
'posts': posts,
}
self.response.headers['Content-Type'] = 'text/html'
self.response.write(template.render(template_values))
示例3: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import query [as 别名]
def get(self):
user = users.get_current_user()
if not user or not users.is_current_user_admin():
self.redirect(users.create_login_url(self.request.uri))
return
posts = Post.query().order(-Post.postedDate)
template = jetpoweredblog.JINJA_ENVIRONMENT.get_template(
'templates/admin/posts.html')
template_values = {
'posts': posts,
}
self.response.headers['Content-Type'] = 'text/html'
self.response.write(template.render(template_values))
示例4: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import query [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" }')