We are very pleased to announce the first alpha-release of twod.wsgi, a library to make WSGI a first-class citizen in Django applications.

twod.wsgi allows Django developers to take advantage of the huge array of existing WSGI software, to integrate 3rd party components which suit your needs or just to improve things which are not within the scope of a Web application framework.

It ships with a PasteDeploy application factory (which gives the enterprise some of what it needs) and full-featured request objects extended by [WebOb](http://pythonpaste.org/webob/. It also gives you the ability to serve WSGI applications inside Django, so you can filter the requests they get and/or the responses they return (e.g., to implement Single Sign-On mechanisms). And there’s more!

For example, if you wanted to integrate your authentication mechanisms with your Trac application, you could do it in 11 lines of code:

from django.shortcuts import redirect from django.conf import settings from twod.wsgi import call_wsgi_app from trac.web.main import dispatch_request as trac_app def make_trac ( request , path_info ): if path_info . startswith ( "/login" ): return redirect ( request . script_name + "/login" ) elif path_info . startswith ( "/logout" ): return redirect ( request . script_name + "/logout" ) request . environ [ 'trac.env_path' ] = settings . TRAC_PATH return call_wsgi_app ( trac_app , request , path_info )

Don’t be fooled by the “first alpha release”: It’s rock-solid. We’ve been using it for months in our Web site and it’s never ever failed. It just means the API might change in a backwards incompatible way by the final release – Which is very unlikely given how simple it is.

It’s also comprehensively documented and tested. For all these reasons, we believe it’s safe to say it’s production ready.

Be warned, WSGI is very addictive! If you like it, please support it.