Commit 98d513ac by Victor Shnayder

bugfix and added comments

* wasn't passing namespace properly in parse_course_file
parent bf8e70f9
...@@ -26,10 +26,13 @@ import xmodule ...@@ -26,10 +26,13 @@ import xmodule
''' This file will eventually form an abstraction layer between the ''' This file will eventually form an abstraction layer between the
course XML file and the rest of the system. course XML file and the rest of the system.
TODO: Shift everything from xml.dom.minidom to XPath (or XQuery)
''' '''
# ==== This section has no direct dependencies on django ====================================
# NOTE: it does still have some indirect dependencies:
# util.memcache.fasthash (which does not depend on memcache at all)
#
class ContentException(Exception): class ContentException(Exception):
pass pass
...@@ -166,12 +169,15 @@ def parse_course_file(filename, options, namespace): ...@@ -166,12 +169,15 @@ def parse_course_file(filename, options, namespace):
''' '''
Parse a course file with the given options, and return the resulting Parse a course file with the given options, and return the resulting
xml tree object. xml tree object.
Options should be a dictionary including keys Options should be a dictionary including keys
'dev_content': bool, 'dev_content': bool,
'groups' : [list, of, user, groups] 'groups' : [list, of, user, groups]
namespace is used to in searching for the file. Could be e.g. 'course',
'sections'.
''' '''
xml = etree.XML(render_to_string(filename, options, namespace = 'course')) xml = etree.XML(render_to_string(filename, options, namespace=namespace))
return course_xml_process(xml) return course_xml_process(xml)
...@@ -197,7 +203,9 @@ def get_module(tree, module, id_tag, module_id, sections_dirname, options): ...@@ -197,7 +203,9 @@ def get_module(tree, module, id_tag, module_id, sections_dirname, options):
Given the xml tree of the course, get the xml string for a module Given the xml tree of the course, get the xml string for a module
with the specified module type, id_tag, module_id. Looks in with the specified module type, id_tag, module_id. Looks in
sections_dirname for sections. sections_dirname for sections.
'''
id_tag -- use id_tag if the place the module stores its id is not 'id'
'''
# Sanitize input # Sanitize input
if not module.isalnum(): if not module.isalnum():
raise Exception("Module is not alphanumeric") raise Exception("Module is not alphanumeric")
......
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