From d0bbb0f6c95e977b2400ef5321e1cb5b60a81aa4 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 27 Feb 2013 20:43:49 -0500 Subject: [PATCH] use a different query to get all collections. Also don't apply inheritance to course modules, because that's ultimately a no-op --- .../lib/xmodule/xmodule/modulestore/mongo.py | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index 012efb0c27..928040a583 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -2,6 +2,7 @@ import pymongo import sys import logging import copy +import time from bson.son import SON from fs.osfs import OSFS @@ -157,10 +158,15 @@ class MongoModuleStore(ModuleStoreBase): ''' # get all collections in the course, this query should not return any leaf nodes - query = { '_id.org' : location.org, - '_id.course' : location.course, - '_id.revision' : None, - 'definition.children':{'$ne': []} + query = { + '_id.org': location.org, + '_id.course': location.course, + '$or': [ + {"_id.category":"course"}, + {"_id.category":"chapter"}, + {"_id.category":"sequential"}, + {"_id.category":"vertical"} + ] } # we just want the Location, children, and metadata record_filter = {'_id':1,'definition.children':1,'metadata':1} @@ -279,6 +285,13 @@ class MongoModuleStore(ModuleStoreBase): resource_fs = OSFS(root) + metadata_inheritance_tree = None + + # if we are loading a course object, there is no parent to inherit the metadata from + # so don't bother getting it + if item['location']['category'] != 'course': + metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location']), 300) + # TODO (cdodge): When the 'split module store' work has been completed, we should remove # the 'metadata_inheritance_tree' parameter system = CachingDescriptorSystem( @@ -288,7 +301,7 @@ class MongoModuleStore(ModuleStoreBase): resource_fs, self.error_tracker, self.render_template, - metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location']), 60) + metadata_inheritance_tree = metadata_inheritance_tree ) return system.load_item(item['location'])