From 149194c35b25756f8f76879b5550622d0c855e55 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 25 Jul 2008 17:12:25 +0000 Subject: Document response interfce. --- docs/narr/views.rst | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'docs') 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. ``['Hello + world!']`` 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. -- cgit v1.2.3