summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-07-25 17:12:25 +0000
committerChris McDonough <chrism@agendaless.com>2008-07-25 17:12:25 +0000
commit149194c35b25756f8f76879b5550622d0c855e55 (patch)
tree8dd6304376e1b081ab0e74a17475f3b57f1ceb0e /docs
parenta7586f348c6484aa8bc9916f321bbe176149753a (diff)
downloadpyramid-149194c35b25756f8f76879b5550622d0c855e55.tar.gz
pyramid-149194c35b25756f8f76879b5550622d0c855e55.tar.bz2
pyramid-149194c35b25756f8f76879b5550622d0c855e55.zip
Document response interfce.
Diffstat (limited to 'docs')
-rw-r--r--docs/narr/views.rst31
1 files changed, 30 insertions, 1 deletions
diff --git a/docs/narr/views.rst b/docs/narr/views.rst
index eff483c3c..8288a720c 100644
--- a/docs/narr/views.rst
+++ b/docs/narr/views.rst
@@ -4,7 +4,7 @@ Views
A view is a callable which is invoked when a request enters your
application. :mod:`repoze.bfg's` primary job is to find and call a
view when a request reaches it. The view's return value must
-implement the WebOb Response object interface.
+implement the :term:`WebOb` ``Response`` object interface.
Defining a View as a Function
-----------------------------
@@ -28,5 +28,34 @@ request
A WebOb request object representing the current request.
+Response Construction
+---------------------
+
+A view must return an object that implements the :term:`WebOb`
+``Response`` interface. The easiest way to return something that
+implements this interface is to return a ``webob.Response`` object.
+But any object that has the following attributes will work:
+
+status
+
+ The HTTP status code (including the name) for the response.
+ E.g. ``200 OK`` or ``401 Unauthorized``.
+
+headerlist
+
+ A sequence of tuples representing the list of headers that should be
+ set in the response. E.g. ``[('Content-Type', 'text/html'),
+ ('Content-Length', '412')]``
+
+app_iter
+
+ An iterable representing the body of the response. This can be a
+ list, e.g. ``['<html><head></head><body>Hello
+ world!</body></html>']`` or it can be a filelike object, or any
+ other sort of iterable.
+
+If a view happens to return something to the :mod:``repoze.bfg``
+publisher that does not implement this interface, the publisher will
+raise an error.