From 55505e49ae6c28eabc5c04992bfb665e3bde888d Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Sat, 5 Jan 2019 22:53:30 -0500 Subject: [PATCH 1/5] docs: Fix aiohttp.web.Response docs. Indent the parameters for Response in the class documentation so that the link to it is generated. --- docs/web_reference.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/web_reference.rst b/docs/web_reference.rst index 8f3bd0f9950..76182b2d153 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -805,8 +805,8 @@ Response ^^^^^^^^ .. class:: Response(*, body=None, status=200, reason=None, text=None, \ - headers=None, content_type=None, charset=None, zlib_executor_size=sentinel, - zlib_executor=None) + headers=None, content_type=None, charset=None, \ + zlib_executor_size=sentinel, zlib_executor=None) The most usable response class, inherited from :class:`StreamResponse`. From fff2548eea144d4ed4ab3242bca038d8a283ad8c Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Sat, 5 Jan 2019 22:57:46 -0500 Subject: [PATCH 2/5] docs: Adjust json_response TOC level. --- docs/web_reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/web_reference.rst b/docs/web_reference.rst index 76182b2d153..c8e82ca452f 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -1207,7 +1207,7 @@ WebSocketReady json_response -------------- +^^^^^^^^^^^^^ .. function:: json_response([data], *, text=None, body=None, \ status=200, reason=None, headers=None, \ From 7ecd6035dd4f347c9d2ebe5c3ae4bf4ee1914b8d Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Sat, 5 Jan 2019 22:58:15 -0500 Subject: [PATCH 3/5] docs: Add HTTPException class documentation. --- docs/web_reference.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/web_reference.rst b/docs/web_reference.rst index c8e82ca452f..3c6461b8e01 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -1218,6 +1218,40 @@ Return :class:`Response` with predefined ``'application/json'`` content type and *data* encoded by ``dumps`` parameter (:func:`json.dumps` by default). +HTTP Exceptions +^^^^^^^^^^^^^^^ +Errors can also be returned by raising a HTTP exception instance from within +the handler. + +.. class:: HTTPException(*, headers=None, reason=None, text=None, content_type=None) + + Low-level HTTP failure. + + :param headers: headers for the response + :type headers: dict or multidict.CIMultiDict + + :param str reason: reason included in the response + + :param str text: response's body + + :param str content_type: response's content type. This is passed through + to the :class:`Response` initializer. + + Sub-classes of ``HTTPException`` exist for the standard HTTP response codes + as described in :ref:`aiohttp-web-exceptions` and the expected usage is to + simply raise the appropriate exception type to respond with a specific HTTP + response code. + + Since ``HTTPException`` is a sub-class of :class:`Response`, it contains the + methods and properties that allow you to directly manipulate details of the + response. + + .. attribute:: status_code + + HTTP status code for this exception class. This attribute is usually + defined at the class level. ``self.status_code`` is passed to the + :class:`Response` initializer. + .. _aiohttp-web-app-and-router: From f7d8e166f79f4fb90d958296da106fd75e8a2b2b Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Sat, 5 Jan 2019 23:08:18 -0500 Subject: [PATCH 4/5] Add changelog entry. --- CHANGES/3490.doc | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/3490.doc diff --git a/CHANGES/3490.doc b/CHANGES/3490.doc new file mode 100644 index 00000000000..1a7aac9b6f3 --- /dev/null +++ b/CHANGES/3490.doc @@ -0,0 +1 @@ +Add documentation for ``aiohttp.web.HTTPException``. From 877b9b97445ac22c644a349b7b483b6604ec0d54 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sun, 6 Jan 2019 13:54:29 +0200 Subject: [PATCH 5/5] Update spelling_wordlist.txt --- docs/spelling_wordlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index c83dab69dea..aed9e14578f 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -115,6 +115,7 @@ impl incapsulates Indices infos +initializer inline intaking io