Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit df79324

Browse filesBrowse files
committed
Merge pull request #1004 from tseaver/955-rework_datastore_client_using_base
Refresh #955: make datastore.Client derive from base client.
2 parents c98b707 + 4e0deec commit df79324
Copy full SHA for df79324

File tree

Expand file treeCollapse file tree

3 files changed

+222
-197
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+222
-197
lines changed
Open diff view settings
Collapse file

‎gcloud/datastore/client.py‎

Copy file name to clipboardExpand all lines: gcloud/datastore/client.py
+18-8Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from gcloud._helpers import _LocalStack
1919
from gcloud._helpers import _app_engine_id
2020
from gcloud._helpers import _compute_engine_id
21+
from gcloud.client import Client as _BaseClient
2122
from gcloud.datastore import helpers
2223
from gcloud.datastore.connection import Connection
2324
from gcloud.datastore.batch import Batch
@@ -158,7 +159,7 @@ def _extended_lookup(connection, dataset_id, key_pbs,
158159
return results
159160

160161

161-
class Client(object):
162+
class Client(_BaseClient):
162163
"""Convenience wrapper for invoking APIs/factories w/ a dataset ID.
163164
164165
:type dataset_id: string
@@ -167,20 +168,29 @@ class Client(object):
167168
:type namespace: string
168169
:param namespace: (optional) namespace to pass to proxied API methods.
169170
170-
:type connection: :class:`gcloud.datastore.connection.Connection`, or None
171-
:param connection: (optional) connection to pass to proxied API methods
171+
:type credentials: :class:`oauth2client.client.OAuth2Credentials` or
172+
:class:`NoneType`
173+
:param credentials: The OAuth2 Credentials to use for the connection
174+
owned by this client. If not passed (and if no ``http``
175+
object is passed), falls back to the default inferred
176+
from the environment.
177+
178+
:type http: :class:`httplib2.Http` or class that defines ``request()``.
179+
:param http: An optional HTTP object to make requests. If not passed, an
180+
``http`` object is created that is bound to the
181+
``credentials`` for the current object.
172182
"""
183+
_connection_class = Connection
173184

174-
def __init__(self, dataset_id=None, namespace=None, connection=None):
185+
def __init__(self, dataset_id=None, namespace=None,
186+
credentials=None, http=None):
175187
dataset_id = _determine_default_dataset_id(dataset_id)
176188
if dataset_id is None:
177189
raise EnvironmentError('Dataset ID could not be inferred.')
178190
self.dataset_id = dataset_id
179-
if connection is None:
180-
connection = Connection.from_environment()
181-
self.connection = connection
182-
self._batch_stack = _LocalStack()
183191
self.namespace = namespace
192+
self._batch_stack = _LocalStack()
193+
super(Client, self).__init__(credentials, http)
184194

185195
def _push_batch(self, batch):
186196
"""Push a batch/transaction onto our stack.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.