HTTP Errors

To return an HTTP Error as response the minimum required is to set the
status with the right error code. The QP Publisher offers a convenient
shortcut generic method, respond(title, *content, **kwargs), to
quickly do a response, from anywhere within the request processing,
pre-empting the processing of the current hit.

An error response may therefore simply be a call
to this method, e.g.: respond(‘Unauthorized’, ‘Unauthorized’, status=401).
For 401 and 404 errors, dedicated methods
wrap the publisher.respond() method to make returning these frequently
occuring error responses trivial.

Note that QP considers that if an export returns a None value
then the exported resource is Not Found.

Note that even for an error response, Gizmo(QP) takes care to generate a
fully formatted page as per the site template specified for error pages,
with a navigation menu that corresponds to both the user’s privileges as
well as the page’s hierarchical location.