Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.
So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?
Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.
So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?
You shouldn't have to relearn much, since the difference from a developer perspective is just a small wrapper and some server configuration.
From a deployment perspective, the difference is that your python code lives in a separate process from the web browser, which means
a) The python process can be running as another user than the web server. This can be valuable for security, if used right.
b) The web server processes does not need to contain the python runtime. This can be a major boost for performance if the server runs a lot of "other" requests (static files, etc) and some heavy python requests.
WSGI is the standard API, which enables you to choose the webserver, and also put A WSGI pipeline such as Repoze in front of it.
Most Python frameworks implement wsgi. There is mod_wsgi for apache and a SCGI/FastCGI/AJP module + Flup for the others. That way you can have all the advantages of a separate Python process, without being tied to one webserver.
For developing sophisticated web applications in Python, you would probably use a more comprehensive web development framework like DJango, Zope, Turbogears etc. As an application developer, you don't have to worry about WSGI much. All you have to be aware about is that these frameworks support WSGI. The WSGI allows separation of web server and web application code and a system administrator can change the web server as long as the web application is WSGI compliant. If you are developing in one of these frameworks, you would anyway be satisfying this condition.
If you are a web framework developer (that is developing DJango or Zope itself), then you have to understand WSGI in more depth.
mod_wsgi vs. mod_python:
WSGI in general:
[1] - compared to a preforking Apache, which maintains a separate Python interpreter in each process