本文整理汇总了Python中post.Post.all方法的典型用法代码示例。如果您正苦于以下问题:Python Post.all方法的具体用法?Python Post.all怎么用?Python Post.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self):
posts = Post.all().order('-created')
if self.user:
self.render('front.html', posts = posts,username = self.user.name)
else:
self.render('front.html', posts = posts)
示例2: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self):
"""
This renders home page with all posts, sorted by date.
"""
deleted_post_id = self.request.get('deleted_post_id')
posts = greetings = Post.all().order('-created')
self.render('welcome.html', posts=posts,
deleted_post_id=deleted_post_id)
示例3: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self):
posts = Post.all()
if not config.DEBUG and not self.request.host_url.endswith('appspot.com'):
posts.filter('confirmed_at !=', None)
posts.order('-confirmed_at')
values = {
'posts': posts
}
self.response.out.write(helper.render('main', values))
示例4: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self, post_id=None, action=None):
if action is None:
posts = Post.all()
self.response.out.write(helper.render('admin/posts', { 'posts': posts }))
elif action == "delete":
Post.get_by_id(int(post_id)).delete()
return self.redirect('/admin/posts')
elif action == "confirm":
post = Post.get_by_id(int(post_id))
post.confirmed_at = datetime.datetime.today()
post.put()
return self.redirect('/admin/posts')
示例5: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def post(self):
self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
postid = self.request.get("postid")
userid = self.request.get("userid")
posts = []
followed = []
if postid:
query = Post.all()
query.filter("postid = ", postid)
posts = query.fetch(1000)
elif userid:
query = Stream.all()
query.filter("userid = ", userid)
query.order("-created")
posts = query.fetch(30)
query = Relation.all()
query.filter("follower = ", userid)
followed = query.fetch(1000)
resultList = []
for p in posts:
resultTags = []
postkey = ""
outPostid = ""
if postid:
postkey = p.key()
outPostid = postid
else:
postkey = p.postkey.key()
outPostid = p.postkey.postid
query = Tag.all()
query.filter("postkey = ", postkey)
tags = query.fetch(1000)
for t in tags:
found = False
for f in followed:
if t.userid == f.user:
found = True
break
pass
if found or postid:
tag = {'user': t.userid,
'key': t.tag_key,
'value': t.tag_value}
resultTags.append(tag)
pass
resultList.append({'postid': outPostid, 'post': p.post,
'tags': resultTags})
resultStr = json.dumps(resultList, sort_keys=True,
indent=2)
self.response.out.write(resultStr)
示例6: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self):
posts_query = Post.all().order('-date')
paginator = GAEPaginator(posts_query, 100)
page = self.request.GET.get('page', 1)
try:
posts = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
posts = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
posts = paginator.page(paginator.num_pages)
visible_posts = posts.object_list
columns = [[], [], []]
# TODO: calculate contributor ranking fer reals
contributors = {}
for i in range(len(visible_posts)):
columns[i % len(columns)].append(visible_posts[i])
if not visible_posts[i].author:
continue
if visible_posts[i].author in contributors:
contributors[visible_posts[i].author] += 1
else:
contributors[visible_posts[i].author] = 1
sorted_contributors = sorted(contributors.iteritems(), key=operator.itemgetter(1))
sorted_contributors.reverse()
top_contributors = sorted_contributors[0:min(3, len(contributors))]
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
template_values = {
'top_contributors': top_contributors,
'columns': columns,
'url': url,
'url_linktext': url_linktext,
'posts': posts,
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
示例7: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [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)
示例8: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self):
posts = Post.all().order('-created_at')
self.render('front.html', posts=posts)
示例9: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
def get(self):
posts = greetings = Post.all().order('-created')
self.render('front.html', posts = posts)