Thursday, July 07, 2005

Technical: Initial Contact with WSGI and Paste

Checked out Paste and downloaded WSGIUtils today. Installed svn to check out 3rd party packages. Ran through some of the articles on

There was quite a bit of confusion as to what was going on, and the TODO tutorial did not help much. Admittedly after my experience in Java web frameworks I hoped to breeze through this initial learning curve. Getting the tutorial (WebKit and ZPT) running was quick and easy, but there was no clear flow of control to work from.

With Struts, you knew how things tied together -> how different components of the server were called to process an incoming request, where you redirect control to Actions/Servlets, the order in which stuff was done. I think a large part of this plumbing was hidden in and and paster, and the user does not see the connections to

What I did figure out was to use the ""application(environ, start_response)"" overwrite for the URLparser to hijack control of the request and process it. This ties in neatly with PyFileServer's need to bypass urlparser, since the URL path requested does not go directly to a webserver-shared script or resource but is translated to a directory file path in the file repository outside of the web application.

Still, I would need to learn that flow of control for future purposes. Any recommendations?

1 comment:

Ian Bicking said...

If you get an exception in your application, you'll see a big traceback that includes all the bits of code you are running through. That might be helpful, even if an unconventional way to explore.

Generally WSGI is the right place to start -- read PEP 333 and understand that. It's very detailed, but not very complicated. Everything in Paste is implemented as middleware, and that's what you'll interact with. Things like SitePage are part of the Webware web application framework, and that really isn't the level you are working on here -- you want to work close to HTTP, and WSGI gives you that.