WebOb 1.1 Final

WebOb 1.1 is now final. It had a lengthy beta and release candidate period, so you should be able to upgrade with very little disruption. Having said that, we deprecated a couple of things that you should know about.

A lot of these changes are a step towards Python 3 compatibility. We try to make the API as similar as possible on both versions and that means deprecating and renaming a number of attributes and methods.

What’s deprecated?

  • Python 2.4 is no longer supported
  • req.str_GET, str_POST, str_params and str_cookies — these are not used much and don’t make sense on Python 3.
  • req.decode_param_names for the same reason.
  • accept.first_match(..) — use .best_match(..) instead.
  • HTTPException.exception attribute — this was a workaround to allow raising HTTPExceptions that is no longer needed.
  • Request.unicode_body and .ubody — these attributes will continue to work, but the canonical name now is .text.

Most of these deprecations will be raising errors in WebOb 1.2, so if you’re see any warnings don’t put off fixing them for too long.

What’s new?

  • .POST, .GET, .params and .cookies keys are now unicode by default, this is the only behavior that will work on Python 3 so it makes sense to change the default on Python 2 as well.
  • As always, a number of bugs were fixed (I’ve been keeping WebOb at zero open bugs for pretty much forever, bugs are fixed as soon as they are reported).
  • One long-standing bug deserves a special mention, even more so as it’s a problem that is not limited to WebOb but to almost every WSGI application out there. I will explain this in more detail later, but the short version is this: WSGI does not specify what a server is to do when user-agent disconnects before sending the entire request. Some servers will raise an error when the application will be reading the request body, but some will not. I’ve added a request body wrapper which is automatically applied to Request.body_file or when parsing the request for .POST that detects this condition and raises an error.

For a more detailed list of changes see news page or even commit log if you don’t mind the verbosity.

What about Python 3 support?

There was quite some effort put into porting WebOb to Python 3. It all started with Chris McDonough organizing a sprint at the PyCon US 2011. The sprint provided WebOb with 100% statement coverage. It’s a great thing in itself, but is also essential for porting to Python 3. It’s quite unlikely the port will be used much initially and the tests are necessary to have any faith in the ported code. Porting could introduce changes to behavior on Python 2 as well, so the 100% test coverage is great to guard against that. Here’s a hopefully complete list of people who contributed: Mariano Mara, Danny Navarro, Alexandre Conrad, Patricio Paez, Whit Morriss, Rob Miller, Reed O’Brien, Chris Shenton, Joe Dallago, Tres Seaver, Casey Duncan, Kai Groner, Chris McDonough.

That sprint made possible to proceed with porting itself. Joe Dallago worked on it as his GSOC project. The summer is gone, but thankfully Joe decided to keep at it. He was new to the WebOb codebase when he started but is doing great progress, and we also have to thank the folks who are helping him out with this: Michael Merickel, Casey Duncan, Whit Morriss and Mike Orr.

I’m trying to help out when I can too, but the more people the better, so if you think you can do some porting drop by #pyramid on freenode or the mailing list.

Plans for WebOb 1.2

I hope to release 1.2 final by the end of the year and have Python 3 support baked in. We intend to drop support for Python 2.5 by that time as well. Another thing I’m considering is migrating to Git (and GitHub) which seem to have a more active community.

Not really related to 1.2, but we have webob.org now and I would like to put something more than just docs there. Again, I don’t have much time to work on that, so if you can help, that would be much appreciated.