~nataliabidart/ubuntuone-control-panel/raise-and-handle-unauthorized

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/webclient.py

  • Committer: Tarmac
  • Author(s): Natalia B. Bidart
  • Date: 2011-03-31 21:46:31 UTC
  • mfrom: (119.2.5 device-list-type-error)
  • Revision ID: tarmac-20110331214631-lzjmngucl3im9vk2
- Made the backend robust against possible None values (or any non basestring instance) sent from the API server (LP: #745790).

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
    def _handler(self, session, msg, d):
50
50
        """Handle the result of an http message."""
51
 
        logger.debug("WebClient: got http response %d for uri %r",
 
51
        logger.debug("got http response %d for uri %r",
52
52
                     msg.status_code, msg.get_uri().to_string(False))
53
53
        data = msg.response_body.data
54
54
        if msg.status_code == 200:
62
62
        """Get a given url from the webservice with credentials."""
63
63
        url = (self.base_url + api_name).encode('utf-8')
64
64
        method = "GET"
65
 
        logger.debug("WebClient: getting url: %s, %s", method, url)
 
65
        logger.debug("getting url: %s, %s", method, url)
66
66
        msg = Soup.Message.new(method, url)
67
67
        add_oauth_headers(msg.request_headers.append, method, url, credentials)
68
68
        d = defer.Deferred()
71
71
 
72
72
    def call_api(self, api_name):
73
73
        """Get a given url from the webservice."""
74
 
        logger.debug("WebClient: calling api: %s", api_name)
 
74
        # this may log device ID's, but only for removals, which is OK
 
75
        logger.debug("calling api: %s", api_name)
75
76
        d = self.get_credentials()
76
77
        d.addCallback(self._call_api_with_creds, api_name)
77
78
        return d