add a set_modulestore_configuration to the modulestore interface. This can be used to pass in settings run the Django tier
This commit is contained in:
@@ -9,8 +9,11 @@ from django.core.cache import get_cache
|
||||
CACHE = get_cache('mongo_metadata_inheritance')
|
||||
for store_name in settings.MODULESTORE:
|
||||
store = modulestore(store_name)
|
||||
store.metadata_inheritance_cache_subsystem = CACHE
|
||||
store.request_cache = RequestCache.get_request_cache()
|
||||
|
||||
store.set_modulestore_configuration({
|
||||
'metadata_inheritance_cache_subsystem': CACHE,
|
||||
'request_cache': RequestCache.get_request_cache()
|
||||
})
|
||||
|
||||
modulestore_update_signal = Signal(providing_args=['modulestore', 'course_id', 'location'])
|
||||
store.modulestore_update_signal = modulestore_update_signal
|
||||
|
||||
@@ -384,6 +384,13 @@ class ModuleStore(object):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_modulestore_configuration(self, config_dict):
|
||||
'''
|
||||
Allows for runtime configuration of the modulestore. In particular this is how the
|
||||
application (LMS/CMS) can pass down Django related configuration information, e.g. caches, etc.
|
||||
'''
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class ModuleStoreBase(ModuleStore):
|
||||
'''
|
||||
@@ -395,6 +402,7 @@ class ModuleStoreBase(ModuleStore):
|
||||
'''
|
||||
self._location_errors = {} # location -> ErrorLog
|
||||
self.metadata_inheritance_cache = None
|
||||
self.request_cache = None
|
||||
self.modulestore_update_signal = None # can be set by runtime to route notifications of datastore changes
|
||||
|
||||
def _get_errorlog(self, location):
|
||||
@@ -439,6 +447,14 @@ class ModuleStoreBase(ModuleStore):
|
||||
return c
|
||||
return None
|
||||
|
||||
def set_modulestore_configuration(self, config_dict):
|
||||
"""
|
||||
This is the base implementation of the interface, all we need to do is store
|
||||
two possible configurations as attributes on the class
|
||||
"""
|
||||
self.metadata_inheritance_cache = config_dict.get('metadata_inheritance_cache_subsystem', None)
|
||||
self.request_cache = config_dict.get('request_cache', None)
|
||||
|
||||
|
||||
def namedtuple_to_son(namedtuple, prefix=''):
|
||||
"""
|
||||
|
||||
@@ -100,7 +100,21 @@ class MixedModuleStore(ModuleStoreBase):
|
||||
return courses
|
||||
|
||||
def get_course(self, course_id):
|
||||
"""
|
||||
returns the course module associated with the course_id
|
||||
"""
|
||||
return self._get_modulestore_for_courseid(course_id).get_course(course_id)
|
||||
|
||||
def get_parent_locations(self, location, course_id):
|
||||
"""
|
||||
returns the parent locations for a given lcoation and course_id
|
||||
"""
|
||||
return self._get_modulestore_for_courseid(course_id).get_parent_locations(location, course_id)
|
||||
|
||||
def set_modulestore_configuration(self, config_dict):
|
||||
"""
|
||||
This implementation of the interface method will pass along the configuration to all ModuleStore
|
||||
instances
|
||||
"""
|
||||
for store in self.modulestores.values():
|
||||
store.set_modulestore_configuration(config_dict)
|
||||
|
||||
@@ -8,8 +8,10 @@ from django.core.cache import get_cache
|
||||
cache = get_cache('mongo_metadata_inheritance')
|
||||
for store_name in settings.MODULESTORE:
|
||||
store = modulestore(store_name)
|
||||
store.metadata_inheritance_cache_subsystem = cache
|
||||
store.request_cache = RequestCache.get_request_cache()
|
||||
store.set_modulestore_configuration({
|
||||
'metadata_inheritance_cache_subsystem': cache,
|
||||
'request_cache': RequestCache.get_request_cache()
|
||||
})
|
||||
|
||||
if hasattr(settings, 'DATADOG_API'):
|
||||
dog_http_api.api_key = settings.DATADOG_API
|
||||
|
||||
Reference in New Issue
Block a user