RFC-7807 implementation for Tornado
This library provides a version of tornado.web.RequestHandler.send_error that speaks application/problem+json instead of HTML. The easiest way to use this library is to inherit from problemdetails.ErrorWriter and raise problemdetails.Problem exceptions instead of HTTPError.
class MyHandler(problemdetails.ErrorWriter, web.RequestHandler):
def get(self):
if not self.do_something_hard():
raise problemdetails.Problem(status_code=500,
title='Failed to do_something_hard')
HTTP/1.1 500 Internal Server Error
Content-Type: application/problem+json
{
"status": 500,
"title": "Failed to do_something_hard",
"type": "https://tools.ietf.org/html/rfc7231#section-6.6.1"
}
You can easily construct more substantial response documents by passing additional keyword parameters to the problemdetails.Problem initializer. They become top-level properties in the response document.
You can also call send_error directly and produce a response docuemnt. The following snippet produces the same output as the previous snippet.
class MyHandler(problemdetails.ErrorWriter, web.RequestHandler):
def get(self):
try:
self.do_something_hard()
except SomeException as error:
self.send_error(500, title="Failed to do_something_hard")
The interface of tornado.web.RequestHandler.send_error is less expressive since keyword parameters may be swallowed by intervening code. The only parameters that are recognized are: instance, title, and type. Use the exception-based interface for more substantial documents.
Metadata
Release files for tornado-problem-details 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tornado_problem_details-1.1.0.tar.gz | 16.9 kB | Without provenance | Details for tornado_problem_details-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tornado_problem_details-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for tornado_problem_details-1.1.0-py3-none-any.whl |
Total release size: 23.3 kB
Release files / tornado_problem_details-1.1.0.tar.gz
| Download URL | tornado_problem_details-1.1.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
918974c8bf892fd2b239ffa7b9f569d3cfadb8d3cd07def1e02c64827c3a298e
|
|
BLAKE2b-256 checksum How to use checksums |
b3398bb6ef0554ecc4f8adc9ef6e05ebe2102e33d2269258f4e06d4c5f459c58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / tornado_problem_details-1.1.0-py3-none-any.whl
| Download URL | tornado_problem_details-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d93cc4233f3bfbf86df341f3c7cf8d0547cc911ff92b5c53e5fdbc44ed69126
|
|
BLAKE2b-256 checksum How to use checksums |
1127df44f88fa4efff5d0f20de8ad4aedc3f2c7e0df3f350fe3b8477bf5ddac2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Security for tornado-problem-details 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.