Last weekend I put together some pretty useful code that converts [CouchDB's external process](http://wiki.apache.org/couchdb/ExternalProcesses) JSON request/responses to a WSGI compliant interface.
This means you should be able to run any modern Python web framework in an external process
The simplest example:
#!/usr/bin/python import couchdb_wsgi def application(environ, start_response): start_response('200 Ok', [('content-type', 'text/plain')]) return ['Hello World'] couchdb_wsgi.CouchDBWSGIHandler(application).run()
But a far more interesting example is running a django app
#!/usr/bin/python import os, sys import couchdb_wsgi django_project = os.path.join(os.path.dirname(__file__), 'mysite') sys.path.append(django_project) os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() couchdb_wsgi.CouchDBWSGIHandler(application).run()
All the code is [up on github](http://github.com/mikeal/couchdb-wsgi) and I’ve written up some solid [Sphinx docs that are up on gh-pages](http://mikeal.github.com/couchdb-wsgi/). I also pushed an [initial release to PyPI](http://pypi.python.org/pypi/couchdb-wsgi).