diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py index 05761a6096..a9b91fe4a5 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/definition_lazy_loader.py @@ -1,5 +1,4 @@ from opaque_keys.edx.locator import DefinitionLocator -from bson import SON class DefinitionLazyLoader(object): @@ -25,9 +24,3 @@ class DefinitionLazyLoader(object): loader pointer with the result so as not to fetch more than once """ return self.modulestore.db_connection.get_definition(self.definition_locator.definition_id) - - def as_son(self): - return SON(( - ('block_type', self.definition_locator.block_type), - ('definition', self.definition_locator.definition_id) - )) diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py index f98081e5f6..7edb808fd4 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py @@ -82,7 +82,6 @@ class MongoConnection(object): host=host, port=port, tz_aware=tz_aware, - document_class=son.SON, **kwargs ), db @@ -167,10 +166,10 @@ class MongoConnection(object): """ case_regex = ur"(?i)^{}$" if ignore_case else ur"{}" return self.course_index.find_one( - son.SON([ - (key_attr, re.compile(case_regex.format(getattr(key, key_attr)))) + { + key_attr: re.compile(case_regex.format(getattr(key, key_attr))) for key_attr in ('org', 'course', 'run') - ]) + } ) def find_matching_course_indexes(self, branch=None, search_targets=None): @@ -182,7 +181,7 @@ class MongoConnection(object): search_targets: If specified, this must be a dictionary specifying field values that must exist in the search_targets of the returned courses """ - query = son.SON() + query = {} if branch is not None: query['versions.{}'.format(branch)] = {'$exists': True} @@ -206,11 +205,11 @@ class MongoConnection(object): from_index: If set, only update an index if it matches the one specified in `from_index`. """ self.course_index.update( - from_index or son.SON([ - ('org', course_index['org']), - ('course', course_index['course']), - ('run', course_index['run']) - ]), + from_index or { + 'org': course_index['org'], + 'course': course_index['course'], + 'run': course_index['run'], + }, course_index, upsert=False, ) @@ -219,11 +218,11 @@ class MongoConnection(object): """ Delete the course_index from the persistence mechanism whose id is the given course_index """ - return self.course_index.remove(son.SON([ - ('org', course_index['org']), - ('course', course_index['course']), - ('run', course_index['run']) - ])) + return self.course_index.remove({ + 'org': course_index['org'], + 'course': course_index['course'], + 'run': course_index['run'], + }) def get_definition(self, key): """