First Thoughts on WSGI and Paste
I’ve finally had some time to look into WSGI, and I’m starting my first project using it. I made the jump because of how easy mod_wsgi was to get working. I particularly like daemon mode where multiple processes can be configured to run the same application. If, on a particular instance, a wsgi application goes horribly wrong (like calls into a shared object that causes a seg fault), mod_wsgi will happily replace the process with a new copy. I find process isolation in a production environment to be manditory. So go mod_wsgi!
I’ve found Ian Bicking’s work on Python Paste to be most illuminating and good brain food to chew on. I particularly enjoyed his article on a do-it-yourself framework.
The smorgasbord approach to pure WSGI development is very appealing: simple interfaces, low coupling, transparent code, small contexts. It really embodies the values I’ve developed over the years writing Python. Middleware is absolutely scrumptious, and I hope to have some packages suitable for release to the rest of the community after I finish this first project.
So far, I’m using:
I have to say that so far, I’ve been very impressed with paste.urlparser. I’ve written and used so many web dispatch systems over the years, and this one really seems to get it right.
The fact that the dispatch sends to the module level is perfect. Other systems, like cherrypy require you to explicitly import all modules we controller code, usually resulting in many import statements in __init__ modules. paste.urlparser, automatically scans for modules with WSGI applications.
Each module, and in turn each file, is its own application. Simple, clean and to the point. Convention over Configuration.