From 9b134aadf4b1f8878eb80df2a88b1abeefd6302e Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 3 Jul 2012 16:04:18 -0400 Subject: [PATCH] Swallow attempts to create a new item where one already exists --- cms/djangoapps/contentstore/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/__init__.py b/cms/djangoapps/contentstore/__init__.py index 7a38b99b5e..433278c47b 100644 --- a/cms/djangoapps/contentstore/__init__.py +++ b/cms/djangoapps/contentstore/__init__.py @@ -1,5 +1,8 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml import XMLModuleStore +import logging + +log = logging.getLogger(__name__) def import_from_xml(org, course, data_dir): @@ -9,7 +12,14 @@ def import_from_xml(org, course, data_dir): """ module_store = XMLModuleStore(org, course, data_dir, 'xmodule.raw_module.RawDescriptor', eager=True) for module in module_store.modules.itervalues(): - modulestore().create_item(module.location) + + # TODO (cpennington): This forces import to overrite the same items. + # This should in the future create new revisions of the items on import + try: + modulestore().create_item(module.location) + except: + log.exception('Item already exists at %s' % module.location.url()) + pass if 'data' in module.definition: modulestore().update_item(module.location, module.definition['data']) if 'children' in module.definition: