-
Notifications
You must be signed in to change notification settings - Fork 429
Make transport private, remove usage of get_http_object #660
Make transport private, remove usage of get_http_object #660
Conversation
urllib3 = None | ||
|
||
# The available transports, in order of priority. | ||
_TRANSPORTS = tuple(filter(None, (urllib3, httplib2,))) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
try: | ||
from oauth2client._transport import urllib3 | ||
except ImportError: # pragma: NO COVER | ||
urllib3 = None |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ValueError: if no transport can be found for the object. | ||
""" | ||
for transport in _TRANSPORTS: | ||
if isinstance(http_object, transport.HTTP_OBJECT_CLASSES): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if http_object is None: | ||
http_object = _get_preferred_http_object() | ||
|
||
transport = _transport_for_http_object(http_object) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
response, data = http.request( | ||
uri, method=method, body=body, headers=headers, **kwargs) | ||
finally: | ||
http.timeout = original_timeout |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
""" | ||
return self.credentials.authorize( | ||
transport.get_http_object(*args, **kwargs)) | ||
return self.credentials.authorize(http) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"""Returns an authorized http instance. | ||
|
||
Must only be called from within an @oauth_required decorated method, or | ||
from within an @oauth_aware decorated method where has_credentials() | ||
returns True. | ||
|
||
Args: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"""Returns an authorized http instance. | ||
|
||
Can only be called if there are valid credentials for the user, such | ||
as inside of a view that is decorated with @required. | ||
|
||
Args: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
# Make HttpMock instances use the httplib2 transport. | ||
httplib2.HTTP_OBJECT_CLASSES = ( | ||
(http_mock.HttpMock, http_mock.HttpMockSequence) + | ||
httplib2.HTTP_OBJECT_CLASSES) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -481,9 +480,8 @@ def credentials(self): | |||
"""Gets the authorized credentials for this flow, if they exist.""" | |||
return _credentials_from_request(self.request) | |||
|
|||
@property |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM |
Merging with admission of the following:
|
It's broken into 3 separate commits on purpose. The first makes transport private and removes get_http_object, the next two fix everything that breaks when that happens.