From dc17e933393f8b2bd3d51e8e5e1d8e3579570129 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Mon, 1 Apr 2013 11:31:25 -0400 Subject: [PATCH 1/2] per Victor, one shouldn't change the default parameter to a function, since that change is global to the entire lifetime. --- common/lib/xmodule/xmodule/modulestore/xml_importer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 023e7bc9e0..40c35522f6 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -361,7 +361,7 @@ def validate_no_non_editable_metadata(module_store, course_id, category, allowed Assert that there is no metadata within a particular category that we can't support editing However we always allow display_name and 'xml_attribtues' ''' - allowed = allowed + ['xml_attributes', 'display_name'] + _allowed = allowed + ['xml_attributes', 'display_name'] err_cnt = 0 for module_loc in module_store.modules[course_id]: @@ -369,7 +369,7 @@ def validate_no_non_editable_metadata(module_store, course_id, category, allowed if module.location.category == category: my_metadata = dict(own_metadata(module)) for key in my_metadata.keys(): - if key not in allowed: + if key not in _allowed: err_cnt = err_cnt + 1 print ': found metadata on {0}. Studio will not support editing this piece of metadata, so it is not allowed. Metadata: {1} = {2}'. format(module.location.url(), key, my_metadata[key]) From b8f1b744f21669a85832462c667b40b77953f812 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Tue, 2 Apr 2013 14:26:33 -0400 Subject: [PATCH 2/2] fix up defaults per Victor's suggestions --- common/lib/xmodule/xmodule/modulestore/xml_importer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 40c35522f6..7c1f1fb4f7 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -356,12 +356,12 @@ def remap_namespace(module, target_location_namespace): return module -def validate_no_non_editable_metadata(module_store, course_id, category, allowed=[]): +def validate_no_non_editable_metadata(module_store, course_id, category, allowed=None): ''' Assert that there is no metadata within a particular category that we can't support editing - However we always allow display_name and 'xml_attribtues' + However we always allow 'display_name' and 'xml_attribtues' ''' - _allowed = allowed + ['xml_attributes', 'display_name'] + _allowed = (allowed if allowed is not None else []) + ['xml_attributes', 'display_name'] err_cnt = 0 for module_loc in module_store.modules[course_id]: