summaryrefslogtreecommitdiff
path: root/docs/narr/views.rst
blob: a349901bb52e5fd448301224c652fe4c511172ee (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 called when a a request enters your
application.  ``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
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.