当前位置: 首页>>代码示例>>Python>>正文


Python Post.get_all方法代码示例

本文整理汇总了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))
开发者ID:vcelis,项目名称:cs253,代码行数:10,代码来源:handlers.py

示例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)
开发者ID:nathan-sain,项目名称:delicieux,代码行数:57,代码来源:main.py

示例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)
开发者ID:florije1988,项目名称:flask-angular-blog-example,代码行数:7,代码来源:tests.py

示例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)
开发者ID:florije1988,项目名称:flask-angular-blog-example,代码行数:6,代码来源:tests.py

示例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)
开发者ID:IuryAlves,项目名称:pygame-site,代码行数:8,代码来源:usecase.py


注:本文中的models.Post.get_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。