diff options
| author | Ian Bicking <ianb@colorstudy.com> | 2012-04-13 14:05:39 -0500 |
|---|---|---|
| committer | Ian Bicking <ianb@colorstudy.com> | 2012-04-13 14:05:39 -0500 |
| commit | bf89ec583824d2d71b22f7898a6e09a0b9376cd4 (patch) | |
| tree | 95b18d5f20a6e1e7db7e456816898534e924735c /docs | |
| parent | e885a1457ebf32b6227c7e05fbdb560e88a65351 (diff) | |
| download | webob-bf89ec583824d2d71b22f7898a6e09a0b9376cd4.tar.gz | |
Change Response.status_int to Response.status_code (while still supporting .status_int, but changing documentation to prefer status_code)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/comment-example-code/example.py | 7 | ||||
| -rw-r--r-- | docs/comment-example.txt | 4 | ||||
| -rw-r--r-- | docs/differences.txt | 19 | ||||
| -rw-r--r-- | docs/index.txt | 2 | ||||
| -rw-r--r-- | docs/jsonrpc-example-code/jsonrpc.py | 4 | ||||
| -rw-r--r-- | docs/jsonrpc-example.txt | 5 | ||||
| -rw-r--r-- | docs/news.txt | 11 | ||||
| -rw-r--r-- | docs/pycon2011/response_table.rst | 8 | ||||
| -rw-r--r-- | docs/reference.txt | 2 |
9 files changed, 33 insertions, 29 deletions
diff --git a/docs/comment-example-code/example.py b/docs/comment-example-code/example.py index 781acd3..5b50759 100644 --- a/docs/comment-example-code/example.py +++ b/docs/comment-example-code/example.py @@ -5,7 +5,7 @@ import re from cPickle import load, dump from webob import Request, Response, html_escape from webob import exc - + class Commenter(object): def __init__(self, app, storage_dir): @@ -21,7 +21,7 @@ class Commenter(object): # This is the base path of *this* middleware: base_url = req.application_url resp = req.get_response(self.app) - if resp.content_type != 'text/html' or resp.status_int != 200: + if resp.content_type != 'text/html' or resp.status_code != 200: # Not an HTML response, we don't want to # do anything to it return resp(environ, start_response) @@ -145,6 +145,3 @@ if __name__ == '__main__': httpd.serve_forever() except KeyboardInterrupt: print '^C' - - - diff --git a/docs/comment-example.txt b/docs/comment-example.txt index aa6505c..e108382 100644 --- a/docs/comment-example.txt +++ b/docs/comment-example.txt @@ -175,7 +175,7 @@ filter responses that aren't HTML. So we get: def __call__(self, environ, start_response): req = Request(environ) resp = req.get_response(self.app) - if resp.content_type != 'text/html' or resp.status_int != 200: + if resp.content_type != 'text/html' or resp.status_code != 200: return resp(environ, start_response) data = self.get_data(req.url) ... do stuff with data, update resp ... @@ -286,7 +286,7 @@ So here's what this all looks like: # This is the base path of *this* middleware: base_url = req.application_url resp = req.get_response(self.app) - if resp.content_type != 'text/html' or resp.status_int != 200: + if resp.content_type != 'text/html' or resp.status_code != 200: # Not an HTML response, we don't want to # do anything to it return resp(environ, start_response) diff --git a/docs/differences.txt b/docs/differences.txt index 7cc1777..5b3ce84 100644 --- a/docs/differences.txt +++ b/docs/differences.txt @@ -138,7 +138,7 @@ Ordering: ``lists()``: Is ``d.dict_of_lists()`` - + The MultiDict object has a ``d.getone(key)`` method, that raises KeyError if there is not exactly one key. There is a method ``d.mixed()`` which returns a version where values are lists *if* @@ -388,7 +388,7 @@ Response response: In ``res.body`` (settable as ``res.body`` or ``res.app_iter``) status: - In ``res.status_int`` + In ``res.status_code`` mimetype: In ``res.content_type`` @@ -411,7 +411,7 @@ Request ``req.remote_user`` gives the username, but there is no standard place for a user *object*. -``publication``, ``setPublication()``, +``publication``, ``setPublication()``, These are associated with the object publishing system in Zope. This kind of publishing system is outside the scope of WebOb. @@ -441,7 +441,7 @@ Request ``debug``: There is no standard debug flag for WebOb. - + ``__getitem__(key)``, ``get(key)``, etc: These treat the request like a dictionary, which WebOb does not do. They seem to take values from the environment, not @@ -458,7 +458,7 @@ Request Creates a new request that can be used to retry a request. Similar to ``req.copy()``. -``close()``, ``hold(obj)``: +``close()``, ``hold(obj)``: This closes resources associated with the request, including any "held" objects. There's nothing similar. @@ -493,7 +493,7 @@ Response Is ``res.headers.get(name)``. ``getStatus()``: - Is ``res.status_int`` (or ``res.status`` to include reason) + Is ``res.status_code`` (or ``res.status`` to include reason) ``addHeader(name, value)``: Is ``res.headers.add(name, value)`` (in Zope and WebOb, this does @@ -541,7 +541,7 @@ mod_python ========== Some key attributes from the `mod_python -<http://modpython.org/live/current/doc-html/pyapi-mprequest-mem.html>`_ +<http://modpython.org/live/current/doc-html/pyapi-mprequest-mem.html>`_ request object. Request @@ -549,7 +549,7 @@ Request ``req.uri``: In ``req.path``. - + ``req.user``: In ``req.remote_user``. @@ -571,7 +571,7 @@ Response exc = HTTPTemporaryRedirect(location=url) return exc(environ, start_response) -``req.content_type = "application/x-csv"`` and +``req.content_type = "application/x-csv"`` and ``req.headers_out.add('Content-Disposition', 'attachment;filename=somefile.csv')``: .. code-block:: python @@ -695,4 +695,3 @@ this is ``resp.status = code``. The body in PHP is sent implicitly through the rendering of the PHP body (or with ``echo`` or any other functions that send output). - diff --git a/docs/index.txt b/docs/index.txt index f9969ef..03d66a9 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -185,7 +185,7 @@ WSGI): ``response.status``: The response code plus message, like ``'200 OK'``. To set the - code without the reason, use ``response.status_int = 200``. + code without the reason, use ``response.status_code = 200``. ``response.headerlist``: A list of all the headers, like ``[('Content-Type', diff --git a/docs/jsonrpc-example-code/jsonrpc.py b/docs/jsonrpc-example-code/jsonrpc.py index ccd3519..c038992 100644 --- a/docs/jsonrpc-example-code/jsonrpc.py +++ b/docs/jsonrpc-example-code/jsonrpc.py @@ -109,8 +109,8 @@ class _Method(object): req.content_type = 'application/json' req.body = dumps(json) resp = req.get_response(self.parent.proxy) - if resp.status_int != 200 and not ( - resp.status_int == 500 + if resp.status_code != 200 and not ( + resp.status_code == 500 and resp.content_type == 'application/json'): raise ProxyError( "Error from JSON-RPC client %s: %s" diff --git a/docs/jsonrpc-example.txt b/docs/jsonrpc-example.txt index 6ff73f8..d037c72 100644 --- a/docs/jsonrpc-example.txt +++ b/docs/jsonrpc-example.txt @@ -481,8 +481,8 @@ Here's the code to do the call: req.content_type = 'application/json' req.body = dumps(json) resp = req.get_response(self.parent.proxy) - if resp.status_int != 200 and not ( - resp.status_int == 500 + if resp.status_code != 200 and not ( + resp.status_code == 500 and resp.content_type == 'application/json'): raise ProxyError( "Error from JSON-RPC client %s: %s" @@ -651,4 +651,3 @@ Many of these techniques would be better used with a `RESTful <http://en.wikipedia.org/wiki/Representational_State_Transfer>`_ service, so do think about that direction if you are implementing your own protocol. - diff --git a/docs/news.txt b/docs/news.txt index 518cfd9..6b61e5f 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -44,7 +44,7 @@ News SCRIPT_NAME from its WSGI-encoded values. If ``webob.url_encoding`` is not set in the environ and ``url_encoding`` is not passed to the Request constructor, the default value ``utf-8`` will be used to decode the - PATH_INFO and SCRIPT_NAME. + PATH_INFO and SCRIPT_NAME. Note that passing ``url_encoding`` will cause the WSGI environment variable ``webob.url_encoding`` to be set. @@ -53,6 +53,15 @@ News request URI under Python 3. This fixed a problem under Python 3 if you were using non-absolute Location headers in responses. +* Add ``Response.json`` and ``Request.json`` which reads and sets the + body using a JSON encoding (previously only the readable attribute + ``Request.json_body`` existed). ``Request.json_body`` is still + available as an alias. + +* Rename ``Response.status_int`` to ``Response.status_code`` (the + ``.status_int`` name is still available and will be supported + indefinitely). + 1.2b2 ------ diff --git a/docs/pycon2011/response_table.rst b/docs/pycon2011/response_table.rst index 8f98ab1..bdfce0f 100644 --- a/docs/pycon2011/response_table.rst +++ b/docs/pycon2011/response_table.rst @@ -12,16 +12,16 @@ WEBOB NAME write read WERKZEUG NAME default_content_type x x default_mimetype wb default: "text/html", wz: "text/plain" default_charset b b wz uses class var default for charset charset x x charset -unicode_errors b b +unicode_errors b b default_conditional_response b b from_file() (classmethod) b b copy b b status (string) x x status -status_int x x status_code +status_code x x status_code z default_status headers b b -body b b -unicode_body x x data +body b b +unicode_body x x data body_file b File-like obj returned is writeable app_iter b x get_app_iter() z iter_encoded() diff --git a/docs/reference.txt b/docs/reference.txt index f3e9f03..5269e84 100644 --- a/docs/reference.txt +++ b/docs/reference.txt @@ -566,7 +566,7 @@ You can set any of these attributes, e.g.: >>> res.status = 404 >>> res.status '404 Not Found' - >>> res.status_int + >>> res.status_code 404 >>> res.headerlist = [('Content-type', 'text/html')] >>> res.body = 'test' |
