Python API bindings enhancements and fixes
Review Request #3455 — Created Oct. 25, 2012 and submitted — Latest diff uploaded
This patch contains a number of small enhancements and bugfixes for the Python API bindings. 1. Work around django's bug with large base64 encoded multipart form data. Django attempts to decode base64 multipart form data in pieces, causing a 500. To fix this we no longer send the data base64 encoded. urllib2.Request expects the same type of string in it's url and data parameters, so to prevent UnicodeDecodeErrors, we encode the url as 'utf-8'. 2. Add an auth_callback parameter to the sync transport. This callable will be executed when a request requires authorization. This can be used to prompt the user for a username and password. 3. Make the API generate more specific exceptions. A mapping from HTTP status code to exception class is now used to select the exception type. Currently 403 uses a more specific exception type. 4. Fix a bug in the basic auth handler. When calling into urllib2's basic auth handler with username and password of None, a response would not be returned, causing an exception. We now check if the response is None before accessing it. 5. Add the option of disabling proxies to the API.