def create_modulestore_instance(engine, content_store, doc_store_config, options, i18n_service=None, fs_service=None, user_service=None, signal_handler=None):
 class_ = load_function(engine)
 _options = {}
 _options.update(options)
 FUNCTION_KEYS = ['render_template']
 for key in FUNCTION_KEYS:
  if ((key in _options) and isinstance(_options[key], basestring)):
   _options[key] = load_function(_options[key])
 if HAS_REQUEST_CACHE:
  request_cache = RequestCache.get_request_cache()
 else:
  request_cache = None
 try:
  metadata_inheritance_cache = caches['mongo_metadata_inheritance']
 except InvalidCacheBackendError:
  metadata_inheritance_cache = caches['default']
 if issubclass(class_, MixedModuleStore):
  _options['create_modulestore_instance'] = create_modulestore_instance
 if issubclass(class_, BranchSettingMixin):
  _options['branch_setting_func'] = _get_modulestore_branch_setting
 if (HAS_USER_SERVICE and (not user_service)):
  xb_user_service = DjangoXBlockUserService(get_current_user())
 else:
  xb_user_service = None
 if ('read_preference' in doc_store_config):
  doc_store_config['read_preference'] = getattr(ReadPreference, doc_store_config['read_preference'])
 xblock_field_data_wrappers = [load_function(path) for path in settings.XBLOCK_FIELD_DATA_WRAPPERS]
 def fetch_disabled_xblock_types():
  '\n        Get the disabled xblock names, using the request_cache if possible to avoid hitting\n        a database every time the list is needed.\n        '
  if (disabled_xblocks is None):
   return []
  if request_cache:
   if ('disabled_xblock_types' not in request_cache.data):
    request_cache.data['disabled_xblock_types'] = [block.name for block in disabled_xblocks()]
   return request_cache.data['disabled_xblock_types']
  else:
   disabled_xblock_types = [block.name for block in disabled_xblocks()]
  return disabled_xblock_types
 return class_(contentstore=content_store, metadata_inheritance_cache_subsystem=metadata_inheritance_cache, request_cache=request_cache, xblock_mixins=getattr(settings, 'XBLOCK_MIXINS', ()), xblock_select=getattr(settings, 'XBLOCK_SELECT_FUNCTION', None), xblock_field_data_wrappers=xblock_field_data_wrappers, disabled_xblock_types=fetch_disabled_xblock_types, doc_store_config=doc_store_config, i18n_service=(i18n_service or ModuleI18nService), fs_service=(fs_service or xblock.reference.plugins.FSService()), user_service=(user_service or xb_user_service), signal_handler=(signal_handler or SignalHandler(class_)), **_options)

def create_modulestore_instance ( engine , content_store , doc_store_config , options , i18n_service = None , fs_service = None , user_service = None , signal_handler = None ) : class_ = load_function ( engine ) _options = { } _options . update ( options ) FUNCTION_KEYS = [ 'render_template' ] for key in FUNCTION_KEYS : if ( ( key in _options ) and isinstance ( _options [ key ] , basestring ) ) : _options [ key ] = load_function ( _options [ key ] ) if HAS_REQUEST_CACHE : request_cache = RequestCache . get_request_cache ( ) else : request_cache = None try : metadata_inheritance_cache = caches [ 'mongo_metadata_inheritance' ] except InvalidCacheBackendError : metadata_inheritance_cache = caches [ 'default' ] if issubclass ( class_ , MixedModuleStore ) : _options [ 'create_modulestore_instance' ] = create_modulestore_instance if issubclass ( class_ , BranchSettingMixin ) : _options [ 'branch_setting_func' ] = _get_modulestore_branch_setting if ( HAS_USER_SERVICE and ( not user_service ) ) : xb_user_service = DjangoXBlockUserService ( get_current_user ( ) ) else : xb_user_service = None if ( 'read_preference' in doc_store_config ) : doc_store_config [ 'read_preference' ] = getattr ( ReadPreference , doc_store_config [ 'read_preference' ] ) xblock_field_data_wrappers = [ load_function ( path ) for path in settings . XBLOCK_FIELD_DATA_WRAPPERS ] def fetch_disabled_xblock_types ( ) : if ( disabled_xblocks is None ) : return [ ] if request_cache : if ( 'disabled_xblock_types' not in request_cache . data ) : request_cache . data [ 'disabled_xblock_types' ] = [ block . name for block in disabled_xblocks ( ) ] return request_cache . data [ 'disabled_xblock_types' ] else : disabled_xblock_types = [ block . name for block in disabled_xblocks ( ) ] return disabled_xblock_types return class_ ( contentstore = content_store , metadata_inheritance_cache_subsystem = metadata_inheritance_cache , request_cache = request_cache , xblock_mixins = getattr ( settings , 'XBLOCK_MIXINS' , ( ) ) , xblock_select = getattr ( settings , 'XBLOCK_SELECT_FUNCTION' , None ) , xblock_field_data_wrappers = xblock_field_data_wrappers , disabled_xblock_types = fetch_disabled_xblock_types , doc_store_config = doc_store_config , i18n_service = ( i18n_service or ModuleI18nService ) , fs_service = ( fs_service or xblock . reference . plugins . FSService ( ) ) , user_service = ( user_service or xb_user_service ) , signal_handler = ( signal_handler or SignalHandler ( class_ ) ) , ** _options )
this will return a new instance of a modulestore given an engine and options .