From b48d08b2c5d269e0154323212635705cee8770f6 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2012 11:40:02 -0400 Subject: [PATCH] Minor changes from pull request 170 --- common/lib/xmodule/xmodule/modulestore/mongo.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index 6a8444718e..d649522b6c 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -23,7 +23,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem): def __init__(self, modulestore, module_data, default_class, resources_fs, render_template): """ modulestore: the module store that can be used to retrieve additional modules - module_data: a mapping of Location -> json that was cached from the underlying modulestore + module_data: a dict mapping Location -> json that was cached from the underlying modulestore default_class: The default_class to use when loading an XModuleDescriptor from the module_data resources_fs: a filesystem, as per MakoDescriptorSystem render_template: a function for rendering templates, as per MakoDescriptorSystem @@ -42,15 +42,15 @@ class CachingDescriptorSystem(MakoDescriptorSystem): return XModuleDescriptor.load_from_json(json_data, self, self.default_class) -def location_to_query(loc): +def location_to_query(location): """ Takes a Location and returns a SON object that will query for that location. - Fields in loc that are None are ignored in the query + Fields in location that are None are ignored in the query """ query = SON() # Location dict is ordered by specificity, and SON # will preserve that order for queries - for key, val in Location(loc).dict().iteritems(): + for key, val in Location(location).dict().iteritems(): if val is not None: query['_id.{key}'.format(key=key)] = val @@ -106,6 +106,7 @@ class MongoModuleStore(ModuleStore): to_process = list(self.collection.find({'_id': {'$in': [Location(child).dict() for child in children]}})) else: to_process = [] + # If depth is None, then we just recurse until we hit all the descendents if depth is not None: depth -= 1