summaryrefslogtreecommitdiff
path: root/docs/narr/webob.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-11-02 03:35:17 -0400
committerChris McDonough <chrism@plope.com>2010-11-02 03:35:17 -0400
commit94b88987fd4f742538ccf43f5789e9c6463bca0e (patch)
tree7fcd2c8bc79c36da71b8f580d036fc834d2ffa3f /docs/narr/webob.rst
parent8129f9ea73ac1c1fcacc3e9ccdd42a12994e7255 (diff)
downloadpyramid-94b88987fd4f742538ccf43f5789e9c6463bca0e.tar.gz
pyramid-94b88987fd4f742538ccf43f5789e9c6463bca0e.tar.bz2
pyramid-94b88987fd4f742538ccf43f5789e9c6463bca0e.zip
- Remove references to 'WebOb' Response and just call it 'Response', and note
that it is imported from pyramid. API docs can mention its inheritance from webob (aka "Provide a webob.Response class facade for forward compat").
Diffstat (limited to 'docs/narr/webob.rst')
-rw-r--r--docs/narr/webob.rst66
1 files changed, 28 insertions, 38 deletions
diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst
index b41979a1f..b496db41e 100644
--- a/docs/narr/webob.rst
+++ b/docs/narr/webob.rst
@@ -186,9 +186,6 @@ If it is set, then ``req.POST``, ``req.GET``, ``req.params``, and
corresponding ``req.str_*`` (like ``req.str_POST``) that is always
``str`` and never unicode.
-.. index::
- single: response object
-
More Details
++++++++++++
@@ -201,13 +198,17 @@ More detail about the request object API is available in:
WebOb documentation will work against request objects created by
:mod:`pyramid`.
+.. index::
+ single: response object
+
Response
~~~~~~~~
-The response object looks a lot like the request object, though with
-some differences. The request object wraps a single ``environ``
-object; the response object has three fundamental parts (based on
-WSGI):
+The :mod:`pyramid` response object can be imported as
+:class:`pyramid.response.Response`. This import location is merely a facade
+for its original location: ``webob.Response``.
+
+A response object has three fundamental parts:
``response.status``:
The response code plus message, like ``'200 OK'``. To set the
@@ -230,12 +231,9 @@ WSGI):
Everything else in the object derives from this underlying state.
Here's the highlights:
-``response.content_type``:
+``response.content_type``
The content type *not* including the ``charset`` parameter.
- Typical use: ``response.content_type = 'text/html'``. You can
- subclass ``Response`` and add a class-level attribute
- ``default_content_type`` to set this automatically on
- instantiation.
+ Typical use: ``response.content_type = 'text/html'``.
``response.charset``:
The ``charset`` parameter of the content-type, it also informs
@@ -243,10 +241,6 @@ Here's the highlights:
``response.content_type_params`` is a dictionary of all the
parameters.
-``response.request``:
- This optional attribute can point to the request object associated
- with this response object.
-
``response.set_cookie(key, value, max_age=None, path='/', ...)``:
Set a cookie. The keyword arguments control the various cookie
parameters. The ``max_age`` argument is the length for the cookie
@@ -295,31 +289,30 @@ argument to the class; e.g.:
.. code-block:: python
- from webob import Response
-
+ from pyramid.response import Response
response = Response(body='hello world!', content_type='text/plain')
-The status defaults to ``'200 OK'``. The content_type does not
-default to anything, though if you subclass ``Response`` and set
+The status defaults to ``'200 OK'``. The content_type does not default to
+anything, though if you subclass :class:`pyramid.response.Response` and set
``default_content_type`` you can override this behavior.
.. index::
single: response exceptions
-Exceptions
-++++++++++
+Exception Responses
++++++++++++++++++++
To facilitate error responses like ``404 Not Found``, the module
-:mod:`webob.exc` contains classes for each kind of error response.
-These include boring but appropriate error bodies. The exceptions
-exposed by this module, when used under :mod:`pyramid`, should be
-imported from the :mod:`pyramid.httpexceptions` "facade" module.
+:mod:`webob.exc` contains classes for each kind of error response. These
+include boring but appropriate error bodies. The exceptions exposed by this
+module, when used under :mod:`pyramid`, should be imported from the
+:mod:`pyramid.httpexceptions` "facade" module. This import location is merely
+a facade for the original location of these exceptions: ``webob.exc``.
-Each class is named ``pyramid.httpexceptions.HTTP*``, where ``*`` is
-the reason for the error. For instance,
-``pyramid.httpexceptions.HTTPNotFound``. It subclasses ``Response``,
-so you can manipulate the instances in the same way. A typical
-example is:
+Each class is named ``pyramid.httpexceptions.HTTP*``, where ``*`` is the reason
+for the error. For instance, :class:`pyramid.httpexceptions.HTTPNotFound`. It
+subclasses :class:`pyramid.Response`, so you can manipulate the instances in
+the same way. A typical example is:
.. ignore-next-block
.. code-block:: python
@@ -359,13 +352,10 @@ objects.
More Details
++++++++++++
-More details about the response object API are available in the `WebOb
-documentation <http://pythonpaste.org/webob>`_ . All methods and
-attributes of a ``webob.Response`` documented within the WebOb
-documentation will work against response objects created by
-:mod:`pyramid`. :mod:`pyramid` does not use a Webob Response
-object subclass to represent a response, it uses WebOb's Response
-class directly.
+More details about the response object API are available in the
+:mod:`pyramid.response` documentation. More details about exception responses
+are in the :mod:`pyramid.httpexceptions` API documentation. The `WebOb
+documentation <http://pythonpaste.org/webob>`_ is also useful.
Multidict
~~~~~~~~~