Commit ef108333 by Calen Pennington

Handle malformed keys in MixedModuleStore configuration

parent 1e27f177
......@@ -40,7 +40,11 @@ class MixedModuleStore(ModuleStoreWriteBase):
try:
self.mappings[CourseKey.from_string(course_id)] = store_name
except InvalidKeyError:
self.mappings[SlashSeparatedCourseKey.from_deprecated_string(course_id)] = store_name
try:
self.mappings[SlashSeparatedCourseKey.from_deprecated_string(course_id)] = store_name
except InvalidKeyError:
log.exception("Invalid MixedModuleStore configuration. Unable to parse course_id %r", course_id)
continue
if 'default' not in stores:
raise Exception('Missing a default modulestore in the MixedModuleStore __init__ method.')
......@@ -50,8 +54,8 @@ class MixedModuleStore(ModuleStoreWriteBase):
if is_xml:
# restrict xml to only load courses in mapping
store['OPTIONS']['course_ids'] = [
course_id
for course_id, store_key in mappings.iteritems()
course_key.to_deprecated_string()
for course_key, store_key in self.mappings.iteritems()
if store_key == key
]
self.modulestores[key] = create_modulestore_instance(
......
......@@ -38,6 +38,7 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
MONGO_COURSEID = 'MITx/999/2013_Spring'
XML_COURSEID1 = 'edX/toy/2012_Fall'
XML_COURSEID2 = 'edX/simple/2012_Fall'
BAD_COURSE_ID = 'edX/simple'
modulestore_options = {
'default_class': DEFAULT_CLASS,
......@@ -53,7 +54,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
'mappings': {
XML_COURSEID1: 'xml',
XML_COURSEID2: 'xml',
MONGO_COURSEID: 'default'
BAD_COURSE_ID: 'xml',
MONGO_COURSEID: 'default',
},
'stores': {
'xml': {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment