'Construct an NDB query for this key range, including the scan direction.
Args:
kind_class: An ndb.Model subclass.
keys_only: bool, default False, use keys_only on Query?
Returns:
An ndb.Query instance.
Raises:
KeyRangeError: if self.direction is not in (KeyRange.ASC, KeyRange.DESC).'

def make_directed_ndb_query(self, kind_class, keys_only=False):

    assert issubclass(kind_class, ndb.Model)
    if keys_only:
        default_options = ndb.QueryOptions(keys_only=True)
    else:
        default_options = None
    query = kind_class.query(app=self._app, namespace=self.namespace, default_options=default_options)
    query = self.filter_ndb_query(query)
    if self.__get_direction(True, False):
        query = query.order(kind_class._key)
    else:
        query = query.order((- kind_class._key))
    return query
