1.5.2 WSGI

The Web Server Gateway Interface (WSGI; PEP 333) is "a proposed standard interface between web servers and Python web applications or frameworks." Its primary goal is straightforward: to make any Python web app work with any web server (Apache, lighttpd, BaseHTTPServer, etc.). Its secondary goal is to enable web apps to be built from decoupled components. The idea is that if the various parts of a web app - security, templating, persistence, etc. - are each modeled as WSGI apps themselves, then they can be strung together in a "middleware stack." Ultimately, it is hoped that WSGI will spur innovation by busting up the monolithic Python web frameworks into smaller components from which one may freely pick and choose.

httpy occupies roughly the same space as WSGI. Each models HTTP within Python by specifying an interface to which your application ought to conform in order to be portable between webservers, given some glue code:

WSGI
app(environ, start_response) calls start_response and returns an iterator over strings

httpy
responder.respond(request) returns a Response object

Furthermore, each wants to recast Python web programming in terms of smaller components rather than monolithic frameworks. But whereas the choice of interfaces is largely a matter of taste, the difference in componentization strategy is more significant.

Under WSGI, the basic building-block for website authors is WSGI middleware. The WSGI vision is of a middleware marketplace, where various subsystems of the web application problem domain - security, templating, persistence, etc. - are packaged and offered as more or less independent WSGI apps. Inter-app communication is handled by extensions to the WSGI protocol: think CGI environment variables set to Python objects instead of strings.

With httpy, on the other hand, the basic building-blocks are Python libraries. Instead of a "middleware stack," you have the standard Python call stack. And instead of "inter-app communication," you simply have Python library APIs. Python is a mature, well-documented, ubiquitous tool. As with HTTP, the premise is that the closer one sticks to bare Python, the better.

httpy is Zeta software. It is copyright © 2006 by Chad Whitacre, and is offered free of charge, warranty, and restrictions.