@classmethod
  @utils.positional(1)
  def query_method(cls,
                   query_fields=(),
                   collection_fields=None,
                   limit_default=QUERY_LIMIT_DEFAULT,
                   limit_max=QUERY_LIMIT_MAX,
                   user_required=False,
                   use_projection=False,
                   **kwargs):
    if REQUEST_MESSAGE in kwargs:
      raise TypeError('Received a request message class on a method intended '
                      'for queries. This is explicitly not allowed. Only '
                      'query_fields can be specified.')

    kwargs[REQUEST_MESSAGE] = cls.ResourceContainer(fields=query_fields)

    if RESPONSE_MESSAGE in kwargs:
      raise TypeError('Received a response message class on a method intended '
                      'for queries. This is explicitly not allowed. Only '
                      'collection_fields can be specified.')
    kwargs[RESPONSE_MESSAGE] = cls.ProtoCollection(
        collection_fields=collection_fields)

    # Only allow GET for queries
    if HTTP_METHOD in kwargs:
      if kwargs[HTTP_METHOD] != QUERY_HTTP_METHOD:
        raise TypeError('Query requests must use the HTTP GET methods. '
                        'Received %s.' % (kwargs[HTTP_METHOD],))
    kwargs[HTTP_METHOD] = QUERY_HTTP_METHOD

    apiserving_method_decorator = endpoints.method(**kwargs)

    def RequestToQueryDecorator(api_method):
      """A decorator that uses the metadata passed to the enclosing method.

      Args:
        api_method: A method to be decorated. Expected signature is two
            positional arguments, an instance object of an API service and a
            variable containing a deserialized API request object, required here
            to be an NDB query object with kind set to the current
            EndpointsModel class.

      Returns:
        A decorated method that uses the metadata of the enclosing method to
            verify the service instance, convert the arguments to ones that can
            be consumed by the decorated method and serialize the method output
            back to a ProtoRPC (collection) message.
      """

      @functools.wraps(api_method)
      def QueryFromRequestMethod(service_instance, request):
        """Stub method to be decorated.

        After creation, will be passed to the standard endpoints.method
        decorator to preserve the necessary method attributes needed for
        endpoints API methods.

        Args:
          service_instance: A ProtoRPC remove service instance.
          request: A ProtoRPC message.

        Returns:
          A ProtoRPC (collection) message, serialized after being returned from
              an NDB query and containing the cursor if there are more results
              and a cursor was returned.

        Raises:
          endpoints.UnauthorizedException: if the user required boolean from
             the metadata is True and if there is no current endpoints user.
          endpoints.ForbiddenException: if the limit passed in through the
             request exceeds the maximum allowed.
        """
        if user_required and endpoints.get_current_user() is None:
          raise endpoints.UnauthorizedException('Invalid token.')

        request_entity = cls.FromMessage(request)
        query_info = request_entity._endpoints_query_info
        query_info.SetQuery()

        # Allow the caller to update the query
        query = api_method(service_instance, query_info.query)

        # Use limit on query info or default if none was set
        request_limit = query_info.limit or limit_default
        if request_limit > limit_max:
          raise endpoints.ForbiddenException(
              QUERY_MAX_EXCEEDED_TEMPLATE % (request_limit, limit_max))

        query_options = {'start_cursor': query_info.cursor}
        if use_projection:
          projection = [value for value in collection_fields
                        if value in cls._properties]
          query_options['projection'] = projection
        items, next_cursor, more_results = query.fetch_page(
            request_limit, **query_options)

        # Don't pass a cursor if there are no more results
        if not more_results:
          next_cursor = None

        return cls.ToMessageCollection(items,
                                       collection_fields=collection_fields,
                                       next_cursor=next_cursor)

      return apiserving_method_decorator(QueryFromRequestMethod)

    return RequestToQueryDecorator
# Update base class global so EndpointsMetaModel can check subclasses against it
Applies generator processing to a loaded data x:
dataset/ETHPy150Open GoogleDeveloperExperts/experts-app-backend/endpoints_proto_datastore/ndb/model.py/EndpointsModel.query_method--crossover with--dataset/ETHPy150Open longubu/datumio/datumio/datagen.py/BaseGenerator.standardize