Effectively retrieve data according to lazy_collection.
        If we have a stored collection, without any result, return an empty list
513161
def _collection(self):
        
        old_sort_limits_and_len_mode = None if self._sort_limits is None else self._sort_limits.copy(), self._len_mode
        old_sorts = None if self._sort is None else self._sort.copy(),\
                    None if self._sort_by_sortedset is None else self._sort_by_sortedset.copy()
        try:
            if self.stored_key and not self._stored_len:
                if self._len_mode:
                    self._len = 0
                    self._len_mode = False
                self._sort_limits = {}
                return []

            # Manage sort desc added by original `__getitem__` when we sort by score
            if self._sort_by_sortedset and self._sort and self._sort.get('desc'):
                self._sort = None
                self._sort_by_sortedset['desc'] = not self._sort_by_sortedset.get('desc', False)

            return super(ExtendedCollectionManager, self)._collection
        finally:
            self._sort_limits, self._len_mode = old_sort_limits_and_len_mode
            self._sort, self._sort_by_sortedset = old_sorts
693980
def get_collection(self, request, **kwargs):
        
        qs = self.queryset(request, **kwargs)

        if self.display_collection_fields:
            display_fields = self.display_collection_fields
        else:
            display_fields = self.display_fields

        if self.paginate_by is not None:
            page = request.GET.get('page', 1)
            paginator = Paginator(qs, self.paginate_by)
            try:
                qs = paginator.page(page).object_list
            except PageNotAnInteger:
                data = _('Invalid `page` parameter: Not a valid integer.')
                return HttpResponseBadRequest(data)
            except EmptyPage:
                data = _('Invalid `page` parameter: Out of range.')
                return HttpResponseBadRequest(data)
        data = [
            self.serialize(obj, ['id'] + list(display_fields)) for obj in qs
        ]
        return HttpResponse(self.json_dumps(data), content_type='application/json')
653233
public static <T> Collection<T> nullToEmpty(Collection<T> collection) {
        return collection == null ? Collections.<T>emptyList() : collection;
    }
135081
def lazy_result(f):
    """"""
    @wraps(f)
    def decorated(ctx, param, value):
        return LocalProxy(lambda: f(ctx, param, value))
    return decorated
527993
def get(self, lazy=False, **kwargs):
        
        result = self._get(limit=2, lazy=lazy, **kwargs)
        if len(result) > 1:
            raise MultipleNodesReturned(repr(kwargs))
        elif not result:
            raise self.source_class.DoesNotExist(repr(kwargs))
        else:
            return result[0]
39884
def _get_list(self, key, operation, create=False):
        
        return self._get_by_type(key, operation, create, b'list', [])
185277
def _populate(self):
        
        if not self._populated:
            logging.debug("Populating lazy list %d (%s)" % (id(self), self.__class__.__name__))
            try:
                self.populate()
                self._populated = True
            except Exception, e:
                logging.debug("Currently unable to populate lazy list: %s" % e)
1240979
def _get_collection(self, collection_uri, request_headers=None):
        """"""

        # get the collection
        status, headers, thecollection = self._rest_get(collection_uri)

        if status != 200:
            msg = self._get_extended_error(thecollection)
            raise exception.IloError(msg)

        while status < 300:
            # verify expected type
            # Don't limit to version 0 here as we will rev to 1.0 at some
            # point hopefully with minimal changes
            ctype = self._get_type(thecollection)
            if (ctype not in ['Collection.0', 'Collection.1']):
                raise exception.IloError("collection not found")

            # if this collection has inline items, return those
            # NOTE:  Collections are very flexible in how the represent
            # members.  They can be inline in the collection as members
            # of the 'Items' array, or they may be href links in the
            # links/Members array.  The could actually be both. Typically,
            # iLO implements the inline (Items) for only when the collection
            # is read only.  We have to render it with the href links when an
            # array contains PATCHable items because its complex to PATCH
            # inline collection members.

            if 'Items' in thecollection:
                # iterate items
                for item in thecollection['Items']:
                    # if the item has a self uri pointer,
                    # supply that for convenience.
                    memberuri = None
                    if 'links' in item and 'self' in item['links']:
                        memberuri = item['links']['self']['href']
                    yield 200, None, item, memberuri

            # else walk the member links
            elif ('links' in thecollection and
                  'Member' in thecollection['links']):
                # iterate members
                for memberuri in thecollection['links']['Member']:
                    # for each member return the resource indicated by the
                    # member link
                    status, headers, member = self._rest_get(memberuri['href'])
                    yield status, headers, member, memberuri['href']

            # page forward if there are more pages in the collection
            if ('links' in thecollection and
                    'NextPage' in thecollection['links']):
                next_link_uri = (collection_uri + '?page=' + str(
                                 thecollection['links']['NextPage']['page']))
                status, headers, thecollection = self._rest_get(next_link_uri)

            # else we are finished iterating the collection
            else:
                break
572196
def find_all(self, collection):
        
        obj = getattr(self.db, collection)
        result = obj.find()
        return result
929499
def _get_non_empty_list(cls, iter):
        """"""
        res = []
        for value in iter:
            if hasattr(value, 'items'):
                value = cls._get_non_empty_dict(value) or None
            if value is not None:
                res.append(value)
        return res
1268592
def _get_data_from_empty_list(source, fields='*', first_row=0, count=-1, schema=None):
  
  fields = get_field_list(fields, schema)
  return {'cols': _get_cols(fields, schema), 'rows': []}, 0
279990
def _get_pk(self):
        
        pk = None
        if self._lazy_collection['pks']:
            if len(self._lazy_collection['pks']) > 1:
                raise ValueError('Too much pks !')
            pk = list(self._lazy_collection['pks'])[0]
        return pk
198115
def get_collection(source, name, collection_format, default):
    
    if collection_format in COLLECTION_SEP:
        separator = COLLECTION_SEP[collection_format]
        value = source.get(name, None)
        if value is None:
            return default
        return value.split(separator)
    if collection_format == 'brackets':
        return source.getall(name + '[]', default)
    else:                       # format: multi
        return source.getall(name, default)
359947
def get_collections(self):
        """"""
        if not self.quiet:
            print
            print "Finding " + self.current_collection_type + "s..."

        self.compute_collections()

        if not self.quiet:
            print self.current_similarity_measure, self.current_collection_type, "information:"
            table_contents = [("Collection","Indices","Size")]
            for (i, j, k) in zip(self.collection_indices,self.collection_sizes,self.collection_list):
                table_contents.append(([unit.text for unit in k], i, j))
            print_table(table_contents)
161832
def _fetch_all(self):
        
        if self._result_cache is None:
            self._result_cache = list(self.iterator())
            # TODO: Do we have to test for ValuesListIterable, ValuesIterable,
            # and FlatValuesListIterable here?
            if self._iterable_class == ModelIterable:
                for x in self._result_cache:
                    self._set_item_querytime(x)
        if self._prefetch_related_lookups and not self._prefetch_done:
            self._prefetch_related_objects()
859837
def get_collection(self, path, query, **options):
        
        options = self._merge_options(options)
        if options['iterator_type'] == 'items':
            return CollectionPageIterator(self, path, query, options).items()
        if options['iterator_type'] is None:
            return self.get(path, query, **options)
        raise Exception('Unknown value for "iterator_type" option: {}'.format(
            str(options['iterator_type'])))
650235
def get_families(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.FamilyList(self._results, runtime=self._runtime)