本文整理汇总了Python中models.Post.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python Post.get_all方法的具体用法?Python Post.get_all怎么用?Python Post.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.get_all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_all [as 别名]
def get(self, idx=''):
if idx:
r = Post.get_id(int(idx)).as_dict()
else:
r = [x.as_dict() for x in Post.get_all()]
p = Post.get_id(int(idx)) if idx else Post.get_all()
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
self.response.out.write(json.dumps(r))
示例2: get
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_all [as 别名]
def get(self):
'''Returns all posts. Please use sparingly. Call the update function to see if you need
to fetch this at all.
Arguments:
&tag={TAG}
(optional) Filter by this tag.
&start={xx}
(optional) Start returning posts this many results into the set.
&results={xx}
(optional) Return this many results.
&fromdt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter for posts on this date or later
&todt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter for posts on this date or earlier
&meta=yes
(optional) Include change detection signatures on each item in a
'meta' attribute. Clients wishing to maintain a synchronized local
store of bookmarks should retain the value of this attribute - its
value will change when any significant field of the bookmark changes.
Returns a change manifest of all posts. Call the update function to see if you need
to fetch this at all.
This method is intended to provide information on changed bookmarks without
the necessity of a complete download of all post data.
Each post element returned offers a url attribute containing an URL MD5,
with an associated meta attribute containing the current change detection
signature for that bookmark.
'''
tag = self.request.get('tag', default_value=None)
count = self.request.get('results')
count = int(count) if count else 1000
if 'hashes' in self.request.params:
res = Post.get_all_hashes(tag, count)
else:
res = Post.get_all(tag, count)
context = {
'tag' : tag if tag is not None else ''
}
context.update(self.context)
xml_response = results('posts', res, context)
self.write_xml(xml_response)
示例3: test_delete_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_all [as 别名]
def test_delete_post(self):
post_count = len(Post.get_all())
print post_count
res = self.client.post('/api/v1/post/delete/1')
self.assertEqual(len(Post.get_all()),post_count-1)
示例4: test_add_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_all [as 别名]
def test_add_post(self):
post_count = len(Post.get_all())
res = self.client.post('/api/v1/post',data=dict(title='test title',content='klksdlkjsdklj',author_id=1,tags=[]))
self.assertEquals(len(Post.get_all()),post_count+1)
示例5: delete_all_posts
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_all [as 别名]
def delete_all_posts():
"""This is a slow operation if you have
many posts
"""
for post in Post.get_all():
delete_post(post.id)