-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,19 +43,22 @@ class Entity(dict): | |
>>> dataset.entity('MyEntityKind') | ||
<Entity[{'kind': 'MyEntityKind'}] {}> | ||
- :func:`gcloud.datastore.dataset.Dataset.get_entity` to retrive an existing entity. | ||
- :func:`gcloud.datastore.dataset.Dataset.get_entity` | ||
to retrive an existing entity. | ||
>>> dataset.get_entity(key) | ||
<Entity[{'kind': 'EntityKind', id: 1234}] {'property': 'value'}> | ||
You can the set values on the entity just like you would on any other dictionary. | ||
You can the set values on the entity | ||
just like you would on any other dictionary. | ||
>>> entity['age'] = 20 | ||
>>> entity['name'] = 'JJ' | ||
>>> entity | ||
<Entity[{'kind': 'EntityKind', id: 1234}] {'age': 20, 'name': 'JJ'}> | ||
And you can cast an entity to a regular Python dictionary with the `dict` builtin: | ||
And you can cast an entity to a regular Python dictionary | ||
with the `dict` builtin: | ||
>>> dict(entity) | ||
{'age': 20, 'name': 'JJ'} | ||
|
@@ -68,7 +71,8 @@ def __init__(self, dataset=None, kind=None): | |
self._key = None | ||
|
||
def dataset(self): | ||
"""Get the :class:`gcloud.datastore.dataset.Dataset` in which this entity belonds. | ||
"""Get the :class:`gcloud.datastore.dataset.Dataset` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kleyow
Owner
|
||
in which this entity belonds. | ||
.. note:: | ||
This is based on the :class:`gcloud.datastore.key.Key` set on the entity. | ||
|
@@ -116,12 +120,14 @@ def kind(self): | |
|
||
@classmethod | ||
def from_key(cls, key): | ||
"""Factory method for creating an entity based on the :class:`gcloud.datastore.key.Key`. | ||
"""Factory method for creating an entity based on the | ||
:class:`gcloud.datastore.key.Key`. | ||
This comment has been minimized.
Sorry, something went wrong.
dhermes
|
||
:type key: :class:`gcloud.datastore.key.Key` | ||
:param key: The key for the entity. | ||
:returns: The :class:`Entity` derived from the :class:`gcloud.datastore.key.Key`. | ||
:returns: The :class:`Entity` derived from the | ||
:class:`gcloud.datastore.key.Key`. | ||
This comment has been minimized.
Sorry, something went wrong.
dhermes
|
||
""" | ||
|
||
return cls().key(key) | ||
|
@@ -135,7 +141,8 @@ def from_protobuf(cls, pb, dataset=None): | |
:type key: :class:`gcloud.datastore.datastore_v1_pb2.Entity` | ||
:param key: The Protobuf representing the entity. | ||
:returns: The :class:`Entity` derived from the :class:`gcloud.datastore.datastore_v1_pb2.Entity`. | ||
:returns: The :class:`Entity` derived from the | ||
:class:`gcloud.datastore.datastore_v1_pb2.Entity`. | ||
""" | ||
|
||
# This is here to avoid circular imports. | ||
|
Docstring first line should be a single line.
Change to