Skip to content

Commit 479ea6a

Browse files
committed
add docstring to _set_protobuf_property, remove docstring related to None value
1 parent ad7a4d9 commit 479ea6a

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

gcloud/datastore/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ def save_entity(self, dataset_id, key_pb, properties,
430430
not passed in ``properties`` no longer be set for the entity.
431431
432432
.. note::
433-
When saving an entity to the backend, property value set as
434-
empty lists or None cannot be saved and will be ignored.
433+
When saving an entity to the backend, a property value set as
434+
an empty list cannot be saved and will be ignored.
435435
436436
:type dataset_id: string
437437
:param dataset_id: The ID of the dataset in which to save the entity.

gcloud/datastore/helpers.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,27 @@ def _get_value_from_property_pb(property_pb):
219219

220220

221221
def _set_protobuf_property(property_pb, name, value, indexed):
222+
"""Assign 'name', 'value', 'indexed' to the correct 'property_pb'.
223+
224+
Some value (empty list) cannot be directly assigned; this function handles
225+
them correctly.
226+
227+
:type property_pb: :class:`gcloud.datastore.datastore_v1_pb2.Property`
228+
:param property_pb: The value protobuf to which the value is being
229+
assigned.
230+
231+
:type name: string
232+
:param name: The name to be assigned.
233+
234+
:type value: `datetime.datetime`, boolean, float, integer, string,
235+
:class:`gcloud.datastore.key.Key`,
236+
:class:`gcloud.datastore.entity.Entity`,
237+
:param value: The value to be assigned.
238+
239+
:type indexed: boolean
240+
:param indexed: The flag indicates the property should to be indexed or
241+
not.
242+
"""
222243
if isinstance(value, list) and len(value) == 0:
223244
return
224245

0 commit comments

Comments
 (0)