HTTP request and response

Websauna uses Pyramid’s request processing.

Request and response

The incoming HTTP request is an instance of websauna.system.http.Request.

When your view function returns

  • If the return value is instance of pyramid.response.Response it is processed as is
  • If the return value is a dictionary, as usually it is to pass template context variables to template rendering, a corresponding renderer is invoked to turn the context to a response. The renderer argument to view configuration is a template name. The template engine loads this template and passes the view return value to it as template context.

Routing

Routing to a corresponding view function or class is done by Pyramid’s routing mechanism (URL dispatch <http://docs.pylonsproject.org/projects/pyramid//en/latest/narr/urldispatch.html>, travelsal). You set up this in Initializer.

Related methods include

Tweens

You can install tweens (be’tween) to sit between the routing and view processing to have extensible mechanism which needs to process every request or response.