'A context manager for temporarily changing the default store'

@contextmanager
def default_store(self, store_type):

    if (self.get_modulestore_type(None) != store_type):
        raise ValueError(u'Cannot    set    default    store    to    type    {}'.format(store_type))
    (yield)
