From 70e832457b9b5384f25d49e0ef5c91c7072603d6 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Fri, 26 Sep 2014 21:14:05 -0700 Subject: [PATCH] Making datastore.connection.Connection inherit from base Connection. Fixes #197. --- gcloud/datastore/connection.py | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/gcloud/datastore/connection.py b/gcloud/datastore/connection.py index cd04302496bd..a009045e591e 100644 --- a/gcloud/datastore/connection.py +++ b/gcloud/datastore/connection.py @@ -1,12 +1,13 @@ import httplib2 +from gcloud import connection from gcloud.datastore import datastore_v1_pb2 as datastore_pb from gcloud.datastore import helpers from gcloud.datastore.dataset import Dataset from gcloud.datastore.transaction import Transaction -class Connection(object): +class Connection(connection.Connection): """A connection to the Google Cloud Datastore via the Protobuf API. This class should understand only the basic types (and protobufs) @@ -16,9 +17,6 @@ class Connection(object): :param credentials: The OAuth2 Credentials to use for this connection. """ - API_BASE_URL = 'https://www.googleapis.com' - """The base of the API call URL.""" - API_VERSION = 'v1beta2' """The version of the API, used in building the API call's URL.""" @@ -26,31 +24,9 @@ class Connection(object): '/datasets/{dataset_id}/{method}') """A template used to craft the URL pointing toward a particular API call.""" - _EMPTY = object() - """A pointer to represent an empty value for default arguments.""" - def __init__(self, credentials=None): self._credentials = credentials self._current_transaction = None - self._http = None - - @property - def credentials(self): - return self._credentials - - @property - def http(self): - """A getter for the HTTP transport used in talking to the API. - - :rtype: :class:`httplib2.Http` - :returns: A Http object used to transport data. - """ - - if not self._http: - self._http = httplib2.Http() - if self._credentials: - self._http = self._credentials.authorize(self._http) - return self._http def _request(self, dataset_id, method, data): """Make a request over the Http transport to the Cloud Datastore API. @@ -117,7 +93,7 @@ def build_api_url(cls, dataset_id, method, base_url=None, api_version=None): api_version=(api_version or cls.API_VERSION), dataset_id=dataset_id, method=method) - def transaction(self, transaction=_EMPTY): + def transaction(self, transaction=connection.Connection._EMPTY): if transaction is self._EMPTY: return self._current_transaction else: