wheezy.web / doc / examples.rst


We start with a simple example. Before we proceed let setup virtualenv environment:

$ virtualenv env

Since :ref:`wheezy.web` is template engine agnostic, you need specify extra requirements (per template engine of your choice):

$ env/bin/easy_install wheezy.web[jinja2]
$ env/bin/easy_install wheezy.web[mako]
$ env/bin/easy_install wheezy.web[tenjin]
$ env/bin/easy_install wheezy.web[wheezy.template]


Template application serves template purpose for you. It includes:

  • Integration with both mako and tenjin template system.
  • User registration and authentication.
  • Form validation.

If you are about to start a new project it is a good starting point.

Hello World shows you how to use :ref:`wheezy.web` in a pretty simple WSGI application. It no way pretend to be shortest possible and absolutely not magical:

Handler Contract

Let have a look through each line in this application. First of all let take a look what is a handler:

This one is not changed from what you had in wheezy.http so you are good to keep it minimal. However there is added another one (that actually implements the same handler contract internally):

What is get method here? It is your response to HTTP GET request. You have post for HTTP POST, etc.


Routing is inherited from wheezy.routing. Note that both handlers are working well together:


WSGIApplication is coming from wheezy.http. Integration with wheezy.routing is provided as middleware factory (:py:meth:`~wheezy.web.middleware.path_routing_middleware_factory`):

Functional Tests

You can easily write functional tests for your application using WSGIClient from wheezy.http (file

For more advanced use cases refer to wheezy.http documentation, please.


You can add benchmark of your functional tests (file

Let run benchmark tests with nose (to be run from demos/hello directory):

$ ../../env/bin/nosetests-2.7 -qs -m benchmark

Here is output:

hello: 2 x 20000
baseline throughput change target
  100.0%   11518rps  +0.0% test_welcome
   91.0%   10476rps  +1.1% test_home
Ran 1 test in 3.686s