Archive for the ‘WSGI’ Category.

Module wsgiref doesn't work in Python 3.0 - How to fix it

A very large oddity regarding the newest version of Python is that the wsgiref module is completely broken. Go ahead and try to run the following:

from wsgiref.simple_server import make_server, demo_app
httpd = make_server('', 8000, demo_app)
httpd.handle_request()

You should notice that a nice little "ValueError: need more than 1 value to unpack" message when you try to open it in your web browser. The main ticket for this bug can be found here, and it comes with a patch! If you're running Linux, then the fix is easy. Once you download it simply run this in the command line in the same folder as the patch to issue it:

sudo patch < wsgiref.patch

It will come up with prompts for each of the files to in wsgiref to patch. Simply specify their locations and you're done!

Update: Sources have told me that this has been fixed in Python 3.0.1, so here's hoping.

Python WSGI Middleware for automatic Gzipping

I've just started learning Python WSGI (PEP-333) and thought the best way to learn would be to write some WSGI tools myself. Most recently, I chose to write a middleware application that converts all output into valid gzipped data. In this article, I will be demonstrating how my middleware gzipper works and how to implement it.

Continue reading 'Python WSGI Middleware for automatic Gzipping' »