summaryrefslogtreecommitdiff
path: root/docs/narr/views.rst
blob: eff483c3ccfc01a16a225458f8bcfd57b228ec23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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.

Defining a View as a Function
-----------------------------

The easiest way to define a view is to create a function that accepts
two arguments: *context*, and *request*.  For example, this is a hello
world view implemented as a function::

  def hello_world(context, request):
      from webob import Response
      return Response('Hello world!')

View Arguments
--------------

context

  An instance of a model found via graph traversal.

request

  A WebOb request object representing the current request.