Skip to content

Commit

Permalink
add docstring to _set_protobuf_property, remove docstring related to …
Browse files Browse the repository at this point in the history
…None value
  • Loading branch information
lucemia committed Jan 9, 2015
1 parent ad7a4d9 commit 479ea6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ def save_entity(self, dataset_id, key_pb, properties,
not passed in ``properties`` no longer be set for the entity.
.. note::
When saving an entity to the backend, property value set as
empty lists or None cannot be saved and will be ignored.
When saving an entity to the backend, a property value set as
an empty list cannot be saved and will be ignored.
:type dataset_id: string
:param dataset_id: The ID of the dataset in which to save the entity.
Expand Down
21 changes: 21 additions & 0 deletions gcloud/datastore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ def _get_value_from_property_pb(property_pb):


def _set_protobuf_property(property_pb, name, value, indexed):
"""Assign 'name', 'value', 'indexed' to the correct 'property_pb'.
Some value (empty list) cannot be directly assigned; this function handles
them correctly.
:type property_pb: :class:`gcloud.datastore.datastore_v1_pb2.Property`
:param property_pb: The value protobuf to which the value is being
assigned.
:type name: string
:param name: The name to be assigned.
:type value: `datetime.datetime`, boolean, float, integer, string,
:class:`gcloud.datastore.key.Key`,
:class:`gcloud.datastore.entity.Entity`,
:param value: The value to be assigned.
:type indexed: boolean
:param indexed: The flag indicates the property should to be indexed or
not.
"""
if isinstance(value, list) and len(value) == 0:
return

Expand Down

0 comments on commit 479ea6a

Please sign in to comment.