'A context manager for temporarily setting the branch value for the given course\' store
to the given branch_setting.  If course_id is None, the default store is used.'

@contextmanager
def branch_setting(self, branch_setting, course_id=None):

    store = self._verify_modulestore_support(course_id, 'branch_setting')
    previous_thread_branch_setting = getattr(self.thread_cache, 'branch_setting', None)
    try:
        self.thread_cache.branch_setting = branch_setting
        with store.branch_setting(branch_setting, course_id):
            (yield)
    finally:
        self.thread_cache.branch_setting = previous_thread_branch_setting
