Skip to content

Commit 15b554b

Browse files
committed
Changing datastore Connection to only accept client.
1 parent 076988f commit 15b554b

4 files changed

Lines changed: 89 additions & 101 deletions

File tree

packages/google-cloud-datastore/google/cloud/datastore/_http.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,8 @@ class Connection(connection_module.Connection):
397397
in method arguments, however it should be capable of returning advanced
398398
types.
399399
400-
:type credentials: :class:`oauth2client.client.OAuth2Credentials`
401-
:param credentials: The OAuth2 Credentials to use for this connection.
402-
403-
:type http: :class:`httplib2.Http` or class that defines ``request()``.
404-
:param http: An optional HTTP object to make requests.
400+
:type client: :class:`~google.cloud.datastore.client.Client`
401+
:param client: The client that owns the current connection.
405402
"""
406403

407404
API_BASE_URL = 'https://' + DATASTORE_API_HOST
@@ -414,11 +411,8 @@ class Connection(connection_module.Connection):
414411
'/{project}:{method}')
415412
"""A template for the URL of a particular API call."""
416413

417-
SCOPE = ('https://www.googleapis.com/auth/datastore',)
418-
"""The scopes required for authenticating as a Cloud Datastore consumer."""
419-
420-
def __init__(self, credentials=None, http=None):
421-
super(Connection, self).__init__(credentials=credentials, http=http)
414+
def __init__(self, client):
415+
super(Connection, self).__init__(client)
422416
try:
423417
self.host = os.environ[GCD_HOST]
424418
self.api_base_url = 'http://' + self.host

packages/google-cloud-datastore/google/cloud/datastore/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from google.cloud._helpers import _LocalStack
1919
from google.cloud._helpers import (
2020
_determine_default_project as _base_default_project)
21-
from google.cloud.client import _ClientProjectMixin
22-
from google.cloud.client import Client as _BaseClient
21+
from google.cloud.client import ClientWithProject
2322
from google.cloud.datastore._http import Connection
2423
from google.cloud.datastore import helpers
2524
from google.cloud.datastore.batch import Batch
@@ -143,7 +142,7 @@ def _extended_lookup(connection, project, key_pbs,
143142
return results
144143

145144

146-
class Client(_BaseClient, _ClientProjectMixin):
145+
class Client(ClientWithProject):
147146
"""Convenience wrapper for invoking APIs/factories w/ a project.
148147
149148
.. doctest::
@@ -171,13 +170,14 @@ class Client(_BaseClient, _ClientProjectMixin):
171170
``credentials`` for the current object.
172171
"""
173172

173+
SCOPE = ('https://www.googleapis.com/auth/datastore',)
174+
"""The scopes required for authenticating as a Cloud Datastore consumer."""
175+
174176
def __init__(self, project=None, namespace=None,
175177
credentials=None, http=None):
176-
_ClientProjectMixin.__init__(self, project=project)
177-
_BaseClient.__init__(self, credentials=credentials, http=http)
178-
self._connection = Connection(
179-
credentials=self._credentials, http=self._http)
180-
178+
super(Client, self).__init__(
179+
project=project, credentials=credentials, http=http)
180+
self._connection = Connection(self)
181181
self.namespace = namespace
182182
self._batch_stack = _LocalStack()
183183

0 commit comments

Comments
 (0)