def with_cursor(self, cursor):
    """Set the start of this query to the given serialized cursor.

    When executed, this query will start from the next result for a previous
    invocation of a similar query.

    Returns:
      This Query instance, for chaining.
    """
    try:
      if not cursor:
        raise datastore_errors.BadValueError("Cursor cannot be empty")
      if not isinstance(cursor, basestring):
        raise BadValueError(
            'Cursor must be a str or unicode instance, not a %s'
            % type(cursor).__name__)
      decoded = base64.urlsafe_b64decode(cursor)
      cursor = datastore_pb.CompiledQuery(decoded)
    except (ValueError, TypeError), e:
      raise datastore_errors.BadValueError(
        'Invalid cursor %s. Details: %s' % (cursor, e))
    except Exception, e:
      if e.__class__.__name__ == 'ProtocolBufferDecodeError':
        raise datastore_errors.BadValueError('Invalid cursor %s. '
                                             'Details: %s' % (cursor, e))
      else:
        raise
    self._cursor = cursor
    return self
dataset/ETHPy150Open CollabQ/CollabQ/.google_appengine/google/appengine/ext/db/__init__.py/_BaseQuery.with_cursor/original