Commit b3b118ee by Don Mitchell

Merge pull request #3655 from edx/opaque-keys-common-lib-xmodule

Opaque keys common lib xmodule
parents d5468fff 8827118b
...@@ -182,7 +182,7 @@ class MixedModuleStore(ModuleStoreWriteBase): ...@@ -182,7 +182,7 @@ class MixedModuleStore(ModuleStoreWriteBase):
def delete_course(self, course_key, user_id=None): def delete_course(self, course_key, user_id=None):
""" """
Remove the given course from its modulestore. See xmodule.modulestore.__init__.ModuleStoreWrite.delete_course
""" """
assert(isinstance(course_key, CourseKey)) assert(isinstance(course_key, CourseKey))
store = self._get_modulestore_for_courseid(course_key) store = self._get_modulestore_for_courseid(course_key)
......
...@@ -126,12 +126,16 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -126,12 +126,16 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
""" """
modulestore: the module store that can be used to retrieve additional modules modulestore: the module store that can be used to retrieve additional modules
course_key: the course for which everything in this runtime will be relative
module_data: a dict mapping Location -> json that was cached from the module_data: a dict mapping Location -> json that was cached from the
underlying modulestore underlying modulestore
default_class: The default_class to use when loading an default_class: The default_class to use when loading an
XModuleDescriptor from the module_data XModuleDescriptor from the module_data
cached_metadata: the cache for handling inheritance computation. internal use only
resources_fs: a filesystem, as per MakoDescriptorSystem resources_fs: a filesystem, as per MakoDescriptorSystem
error_tracker: a function that logs errors for later display to users error_tracker: a function that logs errors for later display to users
......
...@@ -154,12 +154,12 @@ def import_from_xml( ...@@ -154,12 +154,12 @@ def import_from_xml(
# of course modules. It will be left as a TBD to implement that # of course modules. It will be left as a TBD to implement that
# method on XmlModuleStore. # method on XmlModuleStore.
course_items = [] course_items = []
for course_id in xml_module_store.modules.keys(): for course_key in xml_module_store.modules.keys():
if target_course_id is not None: if target_course_id is not None:
dest_course_id = target_course_id dest_course_id = target_course_id
else: else:
dest_course_id = course_id dest_course_id = course_key
if create_new_course: if create_new_course:
if store.has_course(dest_course_id, ignore_case=True): if store.has_course(dest_course_id, ignore_case=True):
...@@ -180,17 +180,17 @@ def import_from_xml( ...@@ -180,17 +180,17 @@ def import_from_xml(
course_data_path = None course_data_path = None
if verbose: if verbose:
log.debug("Scanning {0} for course module...".format(course_id)) log.debug("Scanning {0} for course module...".format(course_key))
# Quick scan to get course module as we need some info from there. # Quick scan to get course module as we need some info from there.
# Also we need to make sure that the course module is committed # Also we need to make sure that the course module is committed
# first into the store # first into the store
for module in xml_module_store.modules[course_id].itervalues(): for module in xml_module_store.modules[course_key].itervalues():
if module.scope_ids.block_type == 'course': if module.scope_ids.block_type == 'course':
course_data_path = path(data_dir) / module.data_dir course_data_path = path(data_dir) / module.data_dir
log.debug(u'======> IMPORTING course {course_id}'.format( log.debug(u'======> IMPORTING course {course_key}'.format(
course_id=course_id, course_key=course_key,
)) ))
if not do_import_static: if not do_import_static:
...@@ -205,7 +205,7 @@ def import_from_xml( ...@@ -205,7 +205,7 @@ def import_from_xml(
course = import_module( course = import_module(
module, store, module, store,
course_id, course_key,
dest_course_id, dest_course_id,
do_import_static=do_import_static do_import_static=do_import_static
) )
...@@ -219,13 +219,13 @@ def import_from_xml( ...@@ -219,13 +219,13 @@ def import_from_xml(
# Original wiki_slugs had value location.course. To make them unique this was changed to 'org.course.name'. # Original wiki_slugs had value location.course. To make them unique this was changed to 'org.course.name'.
# If we are importing into a course with a different course_id and wiki_slug is equal to either of these default # If we are importing into a course with a different course_id and wiki_slug is equal to either of these default
# values then remap it so that the wiki does not point to the old wiki. # values then remap it so that the wiki does not point to the old wiki.
if course_id != course.id: if course_key != course.id:
original_unique_wiki_slug = u'{0}.{1}.{2}'.format( original_unique_wiki_slug = u'{0}.{1}.{2}'.format(
course_id.org, course_key.org,
course_id.course, course_key.course,
course_id.run course_key.run
) )
if course.wiki_slug == original_unique_wiki_slug or course.wiki_slug == course_id.course: if course.wiki_slug == original_unique_wiki_slug or course.wiki_slug == course_key.course:
course.wiki_slug = u'{0}.{1}.{2}'.format( course.wiki_slug = u'{0}.{1}.{2}'.format(
course.id.org, course.id.org,
course.id.course, course.id.course,
...@@ -279,7 +279,7 @@ def import_from_xml( ...@@ -279,7 +279,7 @@ def import_from_xml(
) )
# finally loop through all the modules # finally loop through all the modules
for module in xml_module_store.modules[course_id].itervalues(): for module in xml_module_store.modules[course_key].itervalues():
if module.scope_ids.block_type == 'course': if module.scope_ids.block_type == 'course':
# we've already saved the course module up at the top # we've already saved the course module up at the top
# of the loop so just skip over it in the inner loop # of the loop so just skip over it in the inner loop
...@@ -292,7 +292,7 @@ def import_from_xml( ...@@ -292,7 +292,7 @@ def import_from_xml(
import_module( import_module(
module, store, module, store,
course_id, course_key,
dest_course_id, dest_course_id,
do_import_static=do_import_static, do_import_static=do_import_static,
system=course.runtime system=course.runtime
...@@ -306,7 +306,7 @@ def import_from_xml( ...@@ -306,7 +306,7 @@ def import_from_xml(
draft_store, draft_store,
course_data_path, course_data_path,
static_content_store, static_content_store,
course_id, course_key,
dest_course_id, dest_course_id,
course.runtime course.runtime
) )
......
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