http Module

These exceptions may be raised from within view code to send non-200 responses back to the user agent. Within views, this module is available as the http View Variable.

Redirection 3xx

class keystone.http.MovedPermanently(location)

301 Moved Permanently

Raise if the resource has moved, and the user agent should always redirect the user to the new location.

class keystone.http.Found(location)

302 Found

Raise if the resource has moved, but the user agent should request this request URI again in the future.

class keystone.http.SeeOther(location)

303 See Other

Raise if the response to the request can be found at another location, usually sent after successfully processing a POST request.

class keystone.http.NotModified(description=None)

304 Not Modified

Sent in response to a conditional GET request when the user agent’s cached copy is already up to date.

class keystone.http.UseProxy(location)

305 Use Proxy

Indicate that the user-agent should retry the request using the proxy as defined in the Location header.

class keystone.http.TemporaryRedirect(location)

307 Temporary Redirect

Raise if the resource may have moved, and to indicate that the user agent should request this request URI again in the future.

Client Error 4xx

class keystone.http.BadRequest(description=None)

400 Bad Request

Raise if the browser sends something to the application the application or server cannot handle.

class keystone.http.Unauthorized(description=None)

401 Unauthorized

Raise if the user is not authorized. Also used if you want to use HTTP basic auth.

class keystone.http.Forbidden(description=None)

403 Forbidden

Raise if the user doesn’t have the permission for the requested resource but was authenticated.

class keystone.http.NotFound(description=None)

404 Not Found

Raise if a resource does not exist and never existed.

class keystone.http.MethodNotAllowed(valid_methods=None, description=None)

405 Method Not Allowed

Raise if the server used a method the resource does not handle. For example POST if the resource is view only. Especially useful for REST.

The first argument for this exception should be a list of allowed methods. Strictly speaking the response would be invalid if you don’t provide valid methods in the header which you can do with that list.

class keystone.http.NotAcceptable(description=None)

406 Not Acceptable

Raise if the server can’t return any content conforming to the Accept headers of the client.

class keystone.http.RequestTimeout(description=None)

408 Request Timeout

Raise to signalize a timeout.

class keystone.http.Conflict(description=None)

409 Conflict

Raise to signal that a request cannot be completed because it conflicts with the current state on the server.

New in version 0.7.

class keystone.http.Gone(description=None)

410 Gone

Raise if a resource existed previously and went away without new location.

class keystone.http.LengthRequired(description=None)

411 Length Required

Raise if the browser submitted data but no Content-Length header which is required for the kind of processing the server does.

class keystone.http.PreconditionFailed(description=None)

412 Precondition Failed

Status code used in combination with If-Match, If-None-Match, or If-Unmodified-Since.

class keystone.http.RequestEntityTooLarge(description=None)

413 Request Entity Too Large

The status code one should return if the data submitted exceeded a given limit.

class keystone.http.RequestURITooLarge(description=None)

414 Request URI Too Large

Like 413 but for too long URLs.

class keystone.http.UnsupportedMediaType(description=None)

415 Unsupported Media Type

The status code returned if the server is unable to handle the media type the client transmitted.

class keystone.http.RequestedRangeNotSatisfiable(description=None)

416 Requested Range Not Satisfiable

The client asked for a part of the file that lies beyond the end of the file.

New in version 0.7.

class keystone.http.ExpectationFailed(description=None)

417 Expectation Failed

The server cannot meet the requirements of the Expect request-header.

New in version 0.7.

class keystone.http.ImATeapot(description=None)

418 I’m a teapot

The server should return this if it is a teapot and someone attempted to brew coffee with it.

New in version 0.7.

Server Error 5xx

class keystone.http.InternalServerError(description=None)

500 Internal Server Error

Raise if an internal server error occurred. This is a good fallback if an unknown error occurred in the dispatcher.

class keystone.http.NotImplemented(description=None)

501 Not Implemented

Raise if the application does not support the action requested by the browser.

class keystone.http.BadGateway(description=None)

502 Bad Gateway

If you do proxying in your application you should return this status code if you received an invalid response from the upstream server it accessed in attempting to fulfill the request.

class keystone.http.ServiceUnavailable(description=None)

503 Service Unavailable

Status code you should return if a service is temporarily unavailable.

Table Of Contents

This Page