'Add query filter to restrict to this key range.
Args:
query: A db.Query instance.
Returns:
The input query restricted to this key range.'

def filter_query(self, query):

    assert isinstance(query, db.Query)
    if self.include_start:
        start_comparator = '>='
    else:
        start_comparator = '>'
    if self.include_end:
        end_comparator = '<='
    else:
        end_comparator = '<'
    if self.key_start:
        query.filter(('__key__    %s' % start_comparator), self.key_start)
    if self.key_end:
        query.filter(('__key__    %s' % end_comparator), self.key_end)
    return query
