本文整理汇总了Python中model.Post.all方法的典型用法代码示例。如果您正苦于以下问题:Python Post.all方法的具体用法?Python Post.all怎么用?Python Post.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def get(name=None):
if name == None:
posts = Post.all()
posts.order('-date_create')
return render_template('index.html', posts=posts)
else:
try:
post = Post.all().filter('url', name).get()
return render_template('read_post.html', post=post)
except:
abort(404)
示例2: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def get(self, *post_id):
self.response.headers['Content-Type'] = 'application/json; charset=UTF-8'
if post_id:
post = Post.get_by_id(int(post_id[0]))
self.write(json.dumps(post.to_dict()))
else:
posts_query = Post.all().order('-created')
posts = posts_query.fetch(10)
self.write(json.dumps([p.to_dict() for p in posts]))
示例3: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def get(self,tag):
if users.is_current_user_admin():
posts = Post.all().filter('tags', tag).order('-date')
else:
posts = util.getPublicTag(tag) #only cahced public items
if(posts is None):
return self.redirect('/')
else:
template_values = {
'posts': posts,
}
self.generate('../templates/view.html', template_values)
示例4: getPublicPosts
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def getPublicPosts(page):
posts = memcache.get("public_posts")
if posts is not None:
start_ = (page - 1) * PAGESIZE
end_ = start_ + PAGESIZE + 1
return posts[start_:end_]
else:
posts_ = Post.all().filter('private', False).order('-date')
posts = [x for x in posts_]
if not memcache.add("public_posts", posts, 3600):
logging.error("Memcache set failed.")
start_ = (page - 1) * PAGESIZE
end_ = start_ + PAGESIZE + 1
return posts[start_:end_]
示例5: getPublicArchive
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def getPublicArchive(monthyear):
posts = Post.all().filter('monthyear',monthyear).filter('private',False).order('-date')
return posts
示例6: getPublicTag
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def getPublicTag(tag):
posts = Post.all().filter('tags',tag).filter('private',False).order('-date')
return posts
示例7: getPublicCategory
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def getPublicCategory(category):
posts = Post.all().filter('catalog',category).filter('private',False).order('-date')
return posts
示例8: tag
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import all [as 别名]
def tag(name):
"""Método responsável em buscar post com a hash tag informada."""
posts = Post.all()
posts.filter('tags', name)
posts.order('-date_create')
return render_template('index.html', posts=posts)