def raise_410(instance): """Abort the current request with a 410 (Gone) response code. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 410 """ instance.response.status = 410 raise ResponseException(instance.response)
def raise_300(instance): """Abort the current request with a 300 (Multiple Choices) response code. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 300 """ instance.response.status = 300 raise ResponseException(instance.response)
def raise_202(instance): """Abort the current request with a 202 (Accepted) response code. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 202 """ instance.response.status = 202 raise ResponseException(instance.response)
def raise_503(instance): """Abort the current request with a 503 (Service Unavailable) response code. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 503 """ instance.response.status = 503 raise ResponseException(instance.response)
def raise_301(instance, location): """Abort the current request with a 301 (Moved Permanently) response code. Sets the Location header correctly. If the location does not start with a slash, the path of the current request is prepended. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 301 """ _set_location(instance, location) instance.response.status = 301 raise ResponseException(instance.response)
def raise_205(instance): """Abort the current request with a 205 (Reset Content) response code. Clears out the body of the response. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 205 """ instance.response.status = 205 instance.response.body = '' instance.response.body_raw = None raise ResponseException(instance.response)
def raise_501(instance): """Abort the current request with a 501 (Not Implemented) response code. Sets the ``Allow`` response header to the return value of the :func:`Resource.get_allowed_methods` function. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 501 """ instance.response.status = 501 instance.response.headers['Allow'] = instance.get_allowed_methods() raise ResponseException(instance.response)
def raise_500(instance, msg=None): """Abort the current request with a 500 (Internal Server Error) response code. If the message is given it's output as an error message in the response body (correctly converted to the requested MIME type). :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 500 """ instance.response.status = 500 if msg: instance.response.body_raw = {'error': msg} raise ResponseException(instance.response)
def raise_401(instance, authenticate, msg=None): """Abort the current request with a 401 (Unauthorized) response code. If the message is given it's output as an error message in the response body (correctly converted to the requested MIME type). Outputs the WWW-Authenticate header as given by the authenticate parameter. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 401 """ instance.response.status = 401 instance.response.headers['WWW-Authenticate'] = authenticate if msg: instance.response.body_raw = {'error': msg} raise ResponseException(instance.response)
def raise_304(instance): """Abort the current request with a 304 (Not Modified) response code. Clears out the body of the response. :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.Resource` :raises: :class:`webob.exceptions.ResponseException` of status 304 .. todo: The following headers MUST be output: Date, ETag and/or Content-Location, Expires, Cache-Control, Vary. See :rfc:`2616` section 10.3.5. """ instance.response.status = 304 instance.response.body = '' instance.response.body_raw = None raise ResponseException(instance.response)