HTTPExceptions

HTTP exceptions.

HTTPExceptions are for situations that are predicted by the HTTP spec. Where the 200 OK response is typical, a 404 Not Found or 301 Moved Temporarily response is not entirely unexpected.

Application catches all HTTPException exceptions (and subclasses of HTTPException), and instead of being errors these are translated into responses. In various places these can also be caught and changed, for instance an HTTPAuthenticationRequired could be turned into a normal login page.

exception HTTPExceptions.HTTPAuthenticationRequired(realm=None)

Bases: HTTPException

HTTPException “authentication required” subclass.

HTTPAuthenticationRequired will usually cause the browser to open up an HTTP login box, and after getting login information from the user, the browser will resubmit the request. However, this should also trigger login pages in properly set up environments (though much code will not work this way).

Browsers will usually not send authentication information unless they receive this response, even when other pages on the site have given 401 responses before. So when using this authentication every request will usually be doubled, once without authentication, once with.

__init__(realm=None)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

HTTPExceptions.HTTPAuthorizationRequired

alias of HTTPAuthenticationRequired

exception HTTPExceptions.HTTPBadRequest

Bases: HTTPException

HTTPException “bad request” subclass.

When the browser sends an invalid request.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPConflict

Bases: HTTPException

HTTPException “conflict” subclass.

When there’s a locking conflict on this resource (in response to something like a PUT, not for most other conflicts). Mostly for WebDAV.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPException

Bases: Exception

HTTPException template class.

Subclasses must define these variables (usually as class variables):

_code:

a tuple of the integer error code, and the short description that goes with it (like (200, "OK"))

_description:

the long-winded description, to be presented in the response page. Or you can override description() if you want something more context-sensitive.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPForbidden

Bases: HTTPException

HTTPException “forbidden” subclass.

When access is not allowed to this resource. If the user is anonymous, and must be authenticated, then HTTPAuthenticationRequired is a preferable exception. If the user should not be able to get to this resource (at least through the path they did), or is authenticated and still doesn’t have access, or no one is allowed to view this, then HTTPForbidden would be the proper response.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPInsufficientStorage

Bases: HTTPException

HTTPException “insufficient storage” subclass.

When there is not sufficient storage, usually in response to a PUT when there isn’t enough disk space. Mostly for WebDAV.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPMethodNotAllowed

Bases: HTTPException

HTTPException “method not allowed” subclass.

When a method (like GET, PROPFIND, POST, etc) is not allowed on this resource (usually because it does not make sense, not because it is not permitted). Mostly for WebDAV.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPMovedPermanently(location=None, webwareLocation=None)

Bases: HTTPException

HTTPException “moved permanently” subclass.

When a resource is permanently moved. The browser may remember this relocation, and later requests may skip requesting the original resource altogether.

__init__(location=None, webwareLocation=None)

Set destination.

HTTPMovedPermanently needs a destination that you it should be directed to – you can pass location or webwareLocation – if you pass webwareLocation it will be relative to the Webware root location (the mount point of the WSGI application).

args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

We include a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

location()

The location that we will be redirecting to.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPNotFound

Bases: HTTPException

HTTPException “not found” subclass.

When the requested resource does not exist. To be more secretive, it is okay to return a 404 if access to the resource is not permitted (you are not required to use HTTPForbidden, though it makes it more clear why access was disallowed).

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPNotImplemented

Bases: HTTPException

HTTPException “not implemented” subclass.

When methods (like GET, POST, PUT, PROPFIND, etc) are not implemented for this resource.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPPreconditionFailed

Bases: HTTPException

HTTPException “Precondition Failed” subclass.

During compound, atomic operations, when a precondition for an early operation fail, then later operations in will fail with this code. Mostly for WebDAV.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

HTTPExceptions.HTTPRedirect

alias of HTTPTemporaryRedirect

exception HTTPExceptions.HTTPRequestTimeout

Bases: HTTPException

HTTPException “request timeout” subclass.

The client did not produce a request within the time that the server was prepared to wait. The client may repeat the request without modifications at any later time.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPServerError

Bases: HTTPException

HTTPException “Server Error” subclass.

The server encountered an unexpected condition which prevented it from fulfilling the request.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPServiceUnavailable

Bases: HTTPException

HTTPException “service unavailable” subclass.

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPSessionExpired

Bases: HTTPException

HTTPException “session expired” subclass.

This is the same as HTTPAuthenticationRequired, but should be used in the situation when a session has expired.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPTemporaryRedirect(location=None, webwareLocation=None)

Bases: HTTPMovedPermanently

HTTPException “temporary redirect” subclass.

Like HTTPMovedPermanently, except the redirect is only valid for this request. Internally identical to HTTPMovedPermanently, except with a different response code. Browsers will check the server for each request to see where it’s redirected to.

__init__(location=None, webwareLocation=None)

Set destination.

HTTPMovedPermanently needs a destination that you it should be directed to – you can pass location or webwareLocation – if you pass webwareLocation it will be relative to the Webware root location (the mount point of the WSGI application).

args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

We include a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

location()

The location that we will be redirecting to.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception HTTPExceptions.HTTPUnsupportedMediaType

Bases: HTTPException

HTTPException “unsupported media type” subclass.

The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.

__init__(*args, **kwargs)
args
code()

The integer code.

codeMessage()

The message (like Not Found) that goes with the code.

description()

Error description.

Possibly a plain text version of the error description, though usually just identical to htDescription.

headers()

Get headers.

Additional headers that should be sent with the response, not including the Status header. For instance, the redirect exception adds a Location header.

htBody()

The HTML body of the page.

htDescription()

HTML error description.

The HTML description of the error, for presentation to the browser user.

htTitle()

The title, but it may include HTML markup (like italics).

html()

The error page.

The HTML page that should be sent with the error, usually a description of the problem.

setTransaction(trans)

Set transaction.

When the exception is caught by Application, it tells the exception what the transaction is. This way you can resolve relative paths, or otherwise act in a manner sensitive of the context of the error.

title()

The title used in the HTML page.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.