Пример #1
0
    def delete(self, **kwargs):
        """
        Handles DELETE requests. Writes the jsonified output of remove_resources
        to the response object.

        @param version: version of the API (number or "latest")
        @type  version: basestring
        @return: json stringified dict containing rest resources

        Other query arguments include
        limit: the number of resources to delete (batch size)
        projection: a list of strings denoting which attributes should be
                    included in the resources' representations
        keys_only: a boolean which denotes that only the resources' keys
                   should be returned if true
        """
        query = self._validate_query(
            kwargs,
            vol.Schema(
                {
                    vol.Required('version'): basestring,
                    vol.Optional('limit'): val.Coerce(int),
                    vol.Optional('projection'): val.Coerce(
                        val.List(basestring)),
                    vol.Optional('keys_only'): vol.Boolean()
                },
                extra=False))

        resources = self.remove_resources(**query)
        self.response.write(json.dumps(resources))
Пример #2
0
    def delete(self, **kwargs):
        """
        Handles DELETE requests. Writes the jsonified output of remove_resource
        to the response object.

        @param resource_id: identifier for the NDB model instance (usually a
                            urlsafe key)
        @type  resource_id: basestring
        @param version: version of the API (number or "latest")
        @type  version: basestring
        @return: json stringified rest resource

        Other query arguments include
        projection: a list of strings denoting which attributes should be
                    included in the resource's representation
        key_only: a boolean which denotes that only the resource's key should be
                  returned if true
        """
        query = self._validate_query(
            kwargs,
            vol.Schema(
                {
                    vol.Required('resource_id'): basestring,
                    vol.Required('version'): basestring,
                    vol.Optional('projection'): val.Coerce(
                        val.List(basestring)),
                    vol.Optional('key_only'): vol.Boolean()
                },
                extra=False))

        self._set_interface('DELETE', query['version'])
        resource = self.remove_resource(**query)
        self.response.write(json.dumps(resource))