Skip to content

Commit

Permalink
Datastore: Entity doc consistency (#4641)
Browse files Browse the repository at this point in the history
  • Loading branch information
chemelnucfin authored Dec 20, 2017
1 parent bc49824 commit 6275537
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions datastore/google/cloud/datastore/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,28 @@ class Entity(dict):
.. testsetup:: entity-dict
from google.cloud import datastore
from google.cloud import datastore
entity = datastore.Entity()
entity['age'] = 20
entity['name'] = 'JJ'
entity = datastore.Entity()
entity['age'] = 20
entity['name'] = 'JJ'
.. doctest:: entity-dict
>>> sorted(entity.keys())
['age', 'name']
>>> sorted(entity.items())
[('age', 20), ('name', 'JJ')]
>>> sorted(entity.keys())
['age', 'name']
>>> sorted(entity.items())
[('age', 20), ('name', 'JJ')]
.. note::
When saving an entity to the backend, values which are "text"
(``unicode`` in Python2, ``str`` in Python3) will be saved using
the 'text_value' field, after being encoded to UTF-8. When
retrieved from the back-end, such values will be decoded to "text"
again. Values which are "bytes" (``str`` in Python2, ``bytes`` in
Python3), will be saved using the 'blob_value' field, without
any decoding / encoding step.
When saving an entity to the backend, values which are "text"
(``unicode`` in Python2, ``str`` in Python3) will be saved using
the 'text_value' field, after being encoded to UTF-8. When
retrieved from the back-end, such values will be decoded to "text"
again. Values which are "bytes" (``str`` in Python2, ``bytes`` in
Python3), will be saved using the 'blob_value' field, without
any decoding / encoding step.
:type key: :class:`google.cloud.datastore.key.Key`
:param key: Optional key to be set on entity.
Expand Down Expand Up @@ -175,10 +175,11 @@ def kind(self):
"""Get the kind of the current entity.
.. note::
This relies entirely on the :class:`google.cloud.datastore.key.Key`
set on the entity. That means that we're not storing the kind
of the entity at all, just the properties and a pointer to a
Key which knows its Kind.
This relies entirely on the :class:`google.cloud.datastore.key.Key`
set on the entity. That means that we're not storing the kind
of the entity at all, just the properties and a pointer to a
Key which knows its Kind.
"""
if self.key:
return self.key.kind
Expand Down

0 comments on commit 6275537

Please sign in to comment.