Ajaxy Exception Catching

Monday 7 November 2005

I’m only just beginning to dig into all of the Python web frameworks (The Boston Python Meetup group is doing a quickie comparison of frameworks on Thursday, and I’m on the hook for a TurboGears application.) For the most part, I still don’t understand what all the parts are, though I recognize the names going by in my RSS feeds. I read about the developments with a vague interest, because it doesn’t apply to me.

But when I saw Ian Bicking’s Ajaxy Exception Catching screencast, my mouth dropped open. He’s built something (WSGI middleware, what the heck is that?) that catches exceptions in your web application, and displays a stack trace in your browser. Big deal. But you can also expand the line numbers to see context lines of code around the lines themselves. Nice. Then you can expand some more to see all of the local variables at each frame in the stack. Whoa! Then you can type arbitrary Python into an edit control and have it evaluated in the context of that frame. Magic!!


In the context of this case "wsgi middleware" means that my code is implemented as a application that wraps someone else's application. In order for me to wrap your application, I have to provide the same interface as the original app, and that interface happens to be WSGI.

In the end it's mostly just a function call wrapping another function call (like decorators typically do), with a try:except: to catch errors. My function then is invoked inbetween the server and your app -- hence the "middle" in "middleware".

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.