Skip to content

Commit

Permalink
Making datastore.connection.Connection inherit from base Connection.
Browse files Browse the repository at this point in the history
Fixes #197.
  • Loading branch information
dhermes committed Sep 27, 2014
1 parent 4c7fa75 commit 20acc93
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -16,42 +17,18 @@ 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."""

API_URL_TEMPLATE = ('{api_base}/datastore/{api_version}'
'/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.
Expand Down

0 comments on commit 20acc93

Please sign in to comment.