A much more modular way of using the web.session module functions and classes is to use them as Web Server Gateway Interface Middleware. This is described in the web.wsgi.session module documentation which also includes an example.