def get_listing(self, category=None, children=ListingHandler.NONE, count=10, offset=0, content_types=[], date_range=(), exclude=None, **kwargs):
        """
        Get top objects for given category and potentionally also its child categories.

        Params:
            category - Category object to list objects for. None if any category will do
            count - number of objects to output, defaults to 10
            offset - starting with object number... 1-based
            content_types - list of ContentTypes to list, if empty, object from all models are included
            date_range - range for listing's publish_from field
            **kwargs - rest of the parameter are passed to the queryset unchanged
        """
        assert offset >= 0, "Offset must be a positive integer"
        assert count >= 0, "Count must be a positive integer"

        if not count:
            return []

        limit = offset + count

        qset = self.get_listing_queryset(category, children, content_types, date_range, exclude, **kwargs)

        # direct listings, we don't need to check for duplicates
        if children == ListingHandler.NONE:
            return qset[offset:limit]

        seen = set()
        out = []
        while len(out) < count:
            skip = 0
            # 2 i a reasonable value for padding, wouldn't you say dear Watson?
            for l in qset[offset:limit + 2]:
                if l.publishable_id not in seen:
                    seen.add(l.publishable_id)
                    out.append(l)
                    if len(out) == count:
                        break
                else:
                    skip += 1

            # no enough skipped, or not enough listings to work with, no need for another try
            if skip <= 2 or (len(out) + skip) < (count + 2):
                break

            # get another page to fill in the gaps
            offset += count
            limit += count

        return out
def get_listing ( self , category = None , children = ListingHandler . NONE , count = 10 , offset = 0 , content_types = [ ] , date_range = ( ) , exclude = None , ** kwargs ) : assert offset >= 0 , "Offset must be a positive integer" assert count >= 0 , "Count must be a positive integer" if not count : return [ ] limit = offset + count qset = self . get_listing_queryset ( category , children , content_types , date_range , exclude , ** kwargs ) if children == ListingHandler . NONE : return qset [ offset : limit ] seen = set ( ) out = [ ] while len ( out ) < count : skip = 0 for l in qset [ offset : limit + 2 ] : if l . publishable_id not in seen : seen . add ( l . publishable_id ) out . append ( l ) if len ( out ) == count : break else : skip += 1 if skip <= 2 or ( len ( out ) + skip ) < ( count + 2 ) : break offset += count limit += count return out
Get top objects for given category and potentionally also its child categories.

        Params:
            category - Category object to list objects for. None if any category will do
            count - number of objects to output, defaults to 10
            offset - starting with object number... 1-based
            content_types - list of ContentTypes to list, if empty, object from all models are included
            date_range - range for listing's publish_from field
            **kwargs - rest of the parameter are passed to the queryset unchanged