From f462cd6efa099b2bb7386b8ab2c8ad8d0086f2eb Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 20 Mar 2013 15:14:14 -0400 Subject: [PATCH 1/2] if we're loading a course module with depth = 0, then we don't need to fetch/compute inherited metadata --- common/lib/xmodule/xmodule/modulestore/mongo.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index f6b703e806..1cbc053b62 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -376,7 +376,7 @@ class MongoModuleStore(ModuleStoreBase): return data - def _load_item(self, item, data_cache): + def _load_item(self, item, data_cache, depth=0): """ Load an XModuleDescriptor from item, using the children stored in data_cache """ @@ -388,7 +388,11 @@ class MongoModuleStore(ModuleStoreBase): resource_fs = OSFS(root) - metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location'])) + metadata_inheritance_tree = None + # if we are loading a course object, if we're not prefetching children (depth != 0) then don't + # bother with the metadata inheritence + if item['location']['category'] != 'course' or depth != 0: + metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location'])) # TODO (cdodge): When the 'split module store' work has been completed, we should remove # the 'metadata_inheritance_tree' parameter @@ -410,7 +414,7 @@ class MongoModuleStore(ModuleStoreBase): """ data_cache = self._cache_children(items, depth) - return [self._load_item(item, data_cache) for item in items] + return [self._load_item(item, data_cache, depth) for item in items] def get_courses(self): ''' From 133bd767d5b42a9e0e4819a03a14e8c24b9ffd93 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 20 Mar 2013 15:26:29 -0400 Subject: [PATCH 2/2] small refactoring to use a better semantic with regards to the parameter --- common/lib/xmodule/xmodule/modulestore/mongo.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index 1cbc053b62..ea3bdf44d0 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -376,7 +376,7 @@ class MongoModuleStore(ModuleStoreBase): return data - def _load_item(self, item, data_cache, depth=0): + def _load_item(self, item, data_cache, should_apply_metadata_inheritence=True): """ Load an XModuleDescriptor from item, using the children stored in data_cache """ @@ -389,9 +389,8 @@ class MongoModuleStore(ModuleStoreBase): resource_fs = OSFS(root) metadata_inheritance_tree = None - # if we are loading a course object, if we're not prefetching children (depth != 0) then don't - # bother with the metadata inheritence - if item['location']['category'] != 'course' or depth != 0: + + if should_apply_metadata_inheritence: metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location'])) # TODO (cdodge): When the 'split module store' work has been completed, we should remove @@ -414,7 +413,10 @@ class MongoModuleStore(ModuleStoreBase): """ data_cache = self._cache_children(items, depth) - return [self._load_item(item, data_cache, depth) for item in items] + # if we are loading a course object, if we're not prefetching children (depth != 0) then don't + # bother with the metadata inheritence + return [self._load_item(item, data_cache, + should_apply_metadata_inheritence=(item['location']['category'] != 'course' or depth != 0)) for item in items] def get_courses(self): '''