Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Make transport private, remove usage of get_http_object #660

Merged

Conversation

theacodes
Copy link
Contributor

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.

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.

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.

This comment was marked as spam.

This comment was marked as spam.

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.

This comment was marked as spam.

This comment was marked as spam.

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.

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.

This comment was marked as spam.

"""
return self.credentials.authorize(
transport.get_http_object(*args, **kwargs))
return self.credentials.authorize(http)

This comment was marked as spam.

"""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.

"""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.

# 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.

This comment was marked as spam.

This comment was marked as spam.

@@ -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.

@dhermes
Copy link
Contributor

dhermes commented Sep 27, 2016

LGTM

@theacodes
Copy link
Contributor Author

Merging with admission of the following:

  1. I really want to remove any uses of patching _get_preferred_http_object except for the gce check. HTTP should be required everywhere.
  2. The outcome of the conversation over at Internal transport discussion google-auth-library-python#1 will likely have some bearing as to where I take this.

@theacodes theacodes merged commit d4950a6 into googleapis:transport-refactor Sep 27, 2016
@theacodes theacodes deleted the transport-refactor-private branch September 27, 2016 23:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants