'Get the course_index from the persistence mechanism whose id is the given key'

def get_course_index(self, key, ignore_case=False):

    with TIMER.timer('get_course_index', key):
        if ignore_case:
            query = {key_attr: re.compile(u'^{}$'.format(re.escape(getattr(key, key_attr))), re.IGNORECASE) for key_attr in ('org', 'course', 'run')}
        else:
            query = {key_attr: getattr(key, key_attr) for key_attr in ('org', 'course', 'run')}
        return self.course_index.find_one(query)
