1616
1717You'll typically use these to get started with the API:
1818
19+ >>> from gcloud import datastore
1920>>> from gcloud.datastore.entity import Entity
2021>>> from gcloud.datastore.key import Key
2122>>> from gcloud.datastore.query import Query
23+ >>>
24+ >>> datastore.set_default_connection()
25+ >>> datastore.set_default_dataset_id()
26+ >>>
2227>>> key = Key('EntityKind', 1234)
2328>>> entity = Entity(key)
24- >>> query = Query('your-dataset-id', kind='EntityKind')
29+ >>> query = Query(kind='EntityKind')
2530
2631The main concepts with this API are:
2732
3944
4045- :class:`gcloud.datastore.query.Query`
4146 which represents a lookup or search over the rows in the datastore.
47+
48+ - :class:`gcloud.datastore.transaction.Transaction`
49+ which represents an all-or-none transaction and enables consistency
50+ when race conditions may occur.
4251"""
4352
4453import os
4958from gcloud .datastore import helpers
5059
5160
52- SCOPE = ('https://www.googleapis.com/auth/datastore ' ,
61+ SCOPE = ('https://www.googleapis.com/auth/datastore' ,
5362 'https://www.googleapis.com/auth/userinfo.email' )
54- """The scope required for authenticating as a Cloud Datastore consumer."""
63+ """The scopes required for authenticating as a Cloud Datastore consumer."""
5564
5665_DATASET_ENV_VAR_NAME = 'GCLOUD_DATASET_ID'
5766
@@ -92,9 +101,13 @@ def get_connection():
92101 with the same set of credentials (unlikely):
93102
94103 >>> from gcloud import datastore
104+ >>> from gcloud.datastore import Key
105+ >>>
95106 >>> connection = datastore.get_connection()
96- >>> dataset1 = connection.dataset('dataset1')
97- >>> dataset2 = connection.dataset('dataset2')
107+ >>> key1 = Key('Kind', 1234, dataset_id='dataset1')
108+ >>> key2 = Key('Kind', 1234, dataset_id='dataset2')
109+ >>> entity1 = key1.get(connection=connection)
110+ >>> entity2 = key2.get(connection=connection)
98111
99112 :rtype: :class:`gcloud.datastore.connection.Connection`
100113 :returns: A connection defined with the proper credentials.
@@ -110,9 +123,9 @@ def _require_dataset_id(dataset_id=None):
110123 :type dataset_id: :class:`str`.
111124 :param dataset_id: Optional.
112125
113- :rtype: :class:`gcloud.datastore.dataset.Dataset `
114- :returns: A dataset based on the current environment.
115- :raises: :class:`EnvironmentError` if ``dataset_id`` is None,
126+ :rtype: :class:`str `
127+ :returns: A dataset ID based on the current environment.
128+ :raises: :class:`EnvironmentError` if ``dataset_id`` is `` None`` ,
116129 and cannot be inferred from the environment.
117130 """
118131 if dataset_id is None :
@@ -130,7 +143,7 @@ def _require_connection(connection=None):
130143
131144 :rtype: :class:`gcloud.datastore.connection.Connection`
132145 :returns: A connection based on the current environment.
133- :raises: :class:`EnvironmentError` if ``connection`` is None, and
146+ :raises: :class:`EnvironmentError` if ``connection`` is `` None`` , and
134147 cannot be inferred from the environment.
135148 """
136149 if connection is None :
@@ -198,7 +211,7 @@ def allocate_ids(incomplete_key, num_ids, connection=None, dataset_id=None):
198211 :type incomplete_key: A :class:`gcloud.datastore.key.Key`
199212 :param incomplete_key: Partial key to use as base for allocated IDs.
200213
201- :type num_ids: A :class:`int`.
214+ :type num_ids: :class:`int`.
202215 :param num_ids: The number of IDs to allocate.
203216
204217 :type connection: :class:`gcloud.datastore.connection.Connection`
@@ -208,8 +221,8 @@ def allocate_ids(incomplete_key, num_ids, connection=None, dataset_id=None):
208221 :param dataset_id: Optional. The ID of the dataset.
209222
210223 :rtype: list of :class:`gcloud.datastore.key.Key`
211- :returns: The (complete) keys allocated with `incomplete_key` as root.
212- :raises: `ValueError` if `incomplete_key` is not a partial key.
224+ :returns: The (complete) keys allocated with `` incomplete_key` ` as root.
225+ :raises: :class: `ValueError` if `` incomplete_key` ` is not a partial key.
213226 """
214227 connection = _require_connection (connection )
215228 dataset_id = _require_dataset_id (dataset_id )
0 commit comments