def get_all(self, model_query):
        """Returns all model instances of this type matching the given
        query."""

        if model_query.fetch_offset is not None:
            # if possible, attempt to fetch more than we really want so that
            # we can determine if we have more results.  this trick is only
            # possible if fetching w/ offsets
            real_fetch_page_size = model_query.fetch_page_size
            if(model_query.fetch_page_size < MAX_FETCH_PAGE_SIZE):
                model_query.fetch_page_size += 1

        if(model_query.query_expr is None):
            query = self.model_type.all()
            if(model_query.ordering):
                query.order(QUERY_ORDER_PREFIXES[model_query.order_type_idx] +
                            model_query.ordering)
        else:
            if(model_query.ordering):
                model_query.query_expr += (
                    QUERY_ORDERBY + model_query.ordering +
                    QUERY_ORDER_SUFFIXES[model_query.order_type_idx])
            query = self.model_type.gql(model_query.query_expr,
                                        *model_query.query_params)

        if model_query.fetch_offset is None:
            if model_query.fetch_cursor:
                query.with_cursor(model_query.fetch_cursor)

            models = query.fetch(model_query.fetch_page_size)

            if(len(models) == model_query.fetch_page_size):
                try:
                    model_query.next_fetch_offset = (QUERY_CURSOR_PREFIX +
                                                     query.cursor())
                except __HOLE__:
                    # some queries don't allow cursors, fallback to offsets
                    model_query.next_fetch_offset = str(
                        model_query.fetch_page_size)

        else:
            models = query.fetch(model_query.fetch_page_size,
                                 model_query.fetch_offset)

            if(len(models) >= model_query.fetch_page_size):
                model_query.next_fetch_offset = str(real_fetch_page_size +
                                                    model_query.fetch_offset)

            # trim list to the actual size we want
            if(len(models) > real_fetch_page_size):
                models = models[0:real_fetch_page_size]

        return models
dataset/ETHPy150Open jahlborn/appengine-rest-server/src/main/python/rest/__init__.py/ModelHandler.get_all