Python API bindings enhancements and fixes

Review Request #3455 — Created Oct. 25, 2012 and submitted

Information

RBTools
api

Reviewers

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.

 
Description From Last Updated

Should be create_api_error.

chipx86chipx86

Should have parens in the outer conditional, since we're multi-lining. Even though the ( is saving us.

chipx86chipx86

"parameter"

chipx86chipx86

Indentation doesn't match the line above.

chipx86chipx86
chipx86
  1. 
      
  2. rbtools/api/errors.py (Diff revision 1)
     
     
    Should be create_api_error.
  3. rbtools/api/request.py (Diff revision 1)
     
     
     
    Should have parens in the outer conditional, since we're multi-lining. Even though the ( is saving us.
  4. rbtools/api/request.py (Diff revision 1)
     
     
    "parameter"
  5. rbtools/api/request.py (Diff revision 1)
     
     
    Indentation doesn't match the line above.
  6. 
      
SM
david
  1. Ship It!
  2. 
      
chipx86
  1. Ship It!
  2. 
      
SM
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to api (cdee6f8b88)
Loading...