Exemple #1
0
    def cursor_result(self, ordered_props):
        compiled_cursor = datastore_pb.CompiledCursor()
        position = compiled_cursor.add_position()
        position.mutable_key().MergeFrom(self.key)
        position.set_start_inclusive(False)
        if self.prop_name in ordered_props:
            index_value = position.add_indexvalue()
            index_value.set_property(self.prop_name)
            index_value.mutable_value().MergeFrom(self.value)

        return compiled_cursor
  def __init__(self, _cursor_pb=None):
    """Constructor.

    A Cursor constructed with no arguments points the first result of any
    query. If such a Cursor is used as an end_cursor no results will ever be
    returned.
    """
    if _cursor_pb is not None:
      if not isinstance(_cursor_pb, datastore_pb.CompiledCursor):
        raise datastore_errors.BadArgumentError(
            '_cursor_pb argument should be datastore_pb.CompiledCursor (%r)' %
            (_cursor_pb,))
      self.__compiled_cursor = _cursor_pb
    else:
      self.__compiled_cursor = datastore_pb.CompiledCursor()
Exemple #3
0
    def from_bytes(cursor):
        """Gets a Cursor given its byte string serialized form.

    The serialized form of a cursor may change in a non-backwards compatible
    way. In this case cursors must be regenerated from a new Query request.

    Args:
      cursor: A serialized cursor as returned by .to_bytes.

    Returns:
      A Cursor.

    Raises:
      datastore_errors.BadValueError if the cursor argument does not represent a
      serialized cursor.
    """
        try:
            cursor_pb = datastore_pb.CompiledCursor(cursor)
        except (ValueError, TypeError), e:
            raise datastore_errors.BadValueError(
                'Invalid cursor %s. Details: %s' % (cursor, e))
Exemple #4
0
 def cursor_result(self, ordered_props):
     compiled_cursor = datastore_pb.CompiledCursor()
     position = compiled_cursor.add_position()
     position.mutable_key().MergeFrom(self.key)
     position.set_start_inclusive(False)
     return compiled_cursor