View Variables

Keystone makes several objects and functions available within Views as global variables — that is, they need not be declared, they are simply available to your Python and template code.


class Request

A Werkzeug Request instance, available in views as request. The Werkzeug documentation contains a more comlete list of available attributes.


HTTP method name


HTTP cookies, as an ImmutableTypeConversionDict


HTTP GET parameters (query string), as an ImmutableMultiDict


HTTP POST parameters, as an ImmutableMultiDict


Union of args and form.


The actual Response instance is not constructed until after a view’s Python code executes, but aspects of it can be controlled through several View Variables:

class Headers

A Werkzeug Headers instance, available in views as headers. The Werkzeug documentation contains a more comlete list of available attributes and methods.

add(key, value, **kw)

Add the value to the header named key. Keyword arguments can be used to specify additional parameters for the header:

headers.add('Content-Type', 'text/plain')
headers.add('Content-Disposition', 'attachment', filename='blah.txt')
set(key, value, **kw)

Similar to add(), but overwrites any previously set values for headers which accept multiple values.

get(key, default=None, type=None)

Get the value of the header named key, or the default value if no such header is set. Optionally convert using type (a callable of one argument).


Return True if the header named key exists, False otherwise.



Bypass template rendering and immediately return the given body. body may be any iterable object or string.


The http view variable is a module which contains subclasses of HTTPException for returning non-200-status HTTP responses. Full documentation on the exceptions is available at http Module.



The full, absolute path to the root of the Keystone application directory.

Table Of Contents

Previous topic

Keystone Quickstart

Next topic

Advanced Topics

This Page