“Getting” Python Paste

OK, my boss is getting excited about FastCGI and I am spending a lot of my time getting my head around Python Eggs. From what I read on the web the missing link is Paste. So I start googling …

I have tried this before and have found the information on pythonpaste.org rather mystifying. I get the idea of a wsgi toolbox but there must be more to justfy the hype. So this time I looked a little further a field to this post (google hit no. 3, to be precise). This looked more interesting. The paster script appeared to be similar to some of the things Eclipse can do in the Java world: create skeleton projects and deploy web applications.

I new that Paste was heavily into eggs so I decided to start hacking

$ easy_install paste
$ paster create --list-templates
bash paster: command not found

Not a good start, and quite the reverse of what I would expect from an egg-enabled package. Interogating the Paste egg reveals no sign of paster. I must have the wrong package. I dig deeper into pythonpaste.org; there are components called python.deploy and python.script. It could be either of these since paster is a script that deploys stuff. I install both and we are back on track.Now I’ve been forced to look closer at pythonpaste.org I begin to realise the front page is a red herring. The real exciting stuff goes on in Paste Deploy/Script and these are the packages that people usually mean when they evangelise about Paste.

Paste Deploy is a tool for configuring stacks of WSGI components. With it you can plug WSGI applications, middleware and servers together using configuration files and Egg entry points. The Python Deploy docs have an excellent example of how this can work to serve multiple apps from the same server and include HTTP authentication into the mix. This is easily the most impressive use of entry points I have seen.

Paste Script (a.k.a. paster) works closely with Deploy. It allows you to startup a WSGI servers on the command line, including Deploy configurations. Another neat feature is that Paste Script Templates can layout a skeleton project for you, a la Eclipse Projects. Templates are also activated with entry points, therefore framework developers can provide a paste.paster_create_template entry point in their eggs and paster create will create the boilerplate for you.

What I like especially about all this is that it’s just glue and isn’t dependent on any one server or framework. This is, after all, the point of WSGI. You can deploy your app on Paste’s wsgi server or use flup’s FastCGI implementation. Frameworks such as TurboGears and Django are becoming compatible with paste create (by the looks of things there are some issues relating to thread control still to be resolved).

Also the idea of deploying web apps as eggs is very exciting. It invokes a vision of deploying all BADC web services through a common configuration framework with authentication, etc. handled transparently. Thus the app developer needn’t write a single line of authentication code. Paste definitely seems to bring python closer to that vision.

Stop Press: And I now discover the SVN version of Paste has a wsgi filter for OpenId!


About this entry