Helpers

Helper functions for dealing with Cloud Datastore’s Protobuf API.

The non-private functions are part of the API.

class google.cloud.datastore.helpers.GeoPoint(latitude, longitude)

Bases: object

Simple container for a geo point value.

  • Parameters

    • latitude (float) – Latitude of a point.

    • longitude (float) – Longitude of a point.

_eq_(other)

Compare two geo points for equality.

  • Return type

    bool

  • Returns

    True if the points compare equal, else False.

_ne_(other)

Compare two geo points for inequality.

  • Return type

    bool

  • Returns

    False if the points compare equal, else True.

to_protobuf()

Convert the current object to protobuf.

  • Return type

    google.type.latlng_pb2.LatLng.

  • Returns

    The current point as a protobuf.

google.cloud.datastore.helpers.entity_from_protobuf(pb)

Factory method for creating an entity based on a protobuf.

The protobuf should be one returned from the Cloud Datastore Protobuf API.

google.cloud.datastore.helpers.entity_to_protobuf(entity)

Converts an entity into a protobuf.

google.cloud.datastore.helpers.get_read_options(eventual, transaction_id)

Validate rules for read options, and assign to the request.

Helper method for lookup() and run_query.

  • Parameters

    • eventual (bool) – Flag indicating if EVENTUAL or STRONG consistency should be used.

    • transaction_id (bytes) – A transaction identifier (may be null).

  • Return type

    datastore_pb2.ReadOptions

  • Returns

    The read options corresponding to the inputs.

  • Raises

    ValueError if eventual is True and the transaction_id is not None.

google.cloud.datastore.helpers.key_from_protobuf(pb)

Factory method for creating a key based on a protobuf.

The protobuf should be one returned from the Cloud Datastore Protobuf API.