PUTting and DELETEing in python urllib2

Tuesday, October 21st, 2008

The urllib2 Python module makes it pretty simple to GET and POST data using HTTP (and other protocols). But there isn’t a good built-in way to issue HTTP PUT or DELETE requests. I ran into this limitation while working on a project to upload automatically generated documentation to the Mozilla Developer Center. The DekiWiki API for uploading an file attachment uses the HTTP PUT method.

It turns out there is an easy workaround. You can subclass the urllib2.Request class and explicitly override the method:

import urllib2

class RequestWithMethod(urllib2.Request):
  def __init__(self, method, *args, **kwargs):
    self._method = method
    urllib2.Request.__init__(*args, **kwargs)

  def get_method(self):
    return self._method

Preview for Thursday’s post: the generated documentation is already online.

Learning About Tamarin

Monday, November 20th, 2006

When a project like Tamarin is released as open-source, there is naturally a lot of interest in the project. I had a meeting with Eric Shepherd, Jeff Dyer, and Steven Johnson to coordinate a documentation plan for the Tamarin project. This is going to be an incremental process, starting with docs that already exist or are being created within Adobe. We have also identified various documents that we would like to create. I have put up notes from the meeting, for future reference.

If you have questions about Tamarin, feel free to ask them in the mozilla.dev.tech.js-engine newsgroup, or the #tamarin channel on irc.mozilla.org. Once you get your answer, please write an article for the Tamarin documentation on the Mozilla Developer Center.