Commit cb3b17d4 by Calen Pennington

Catch ItemNotFound errors at the top of get_module, rather than in…

Catch ItemNotFound errors at the top of get_module, rather than in get_module_for_descriptor, to maintain previous LMS behavior
parent 0726294c
...@@ -140,21 +140,12 @@ def get_module(user, request, location, student_module_cache, course_id, ...@@ -140,21 +140,12 @@ def get_module(user, request, location, student_module_cache, course_id,
module. If there's an error, will try to return an instance of ErrorModule module. If there's an error, will try to return an instance of ErrorModule
if possible. If not possible, return None. if possible. If not possible, return None.
""" """
location = Location(location)
descriptor = modulestore().get_instance(course_id, location, depth=depth)
return get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id,
position=position, not_found_ok=not_found_ok,
wrap_xmodule_display=wrap_xmodule_display)
def get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id,
position=None, not_found_ok=False, wrap_xmodule_display=True):
"""
Actually implement get_module. See docstring there for details.
"""
try: try:
return _get_module(user, request, descriptor, student_module_cache, course_id, location = Location(location)
position=position, wrap_xmodule_display=wrap_xmodule_display) descriptor = modulestore().get_instance(course_id, location, depth=depth)
return get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id,
position=position, not_found_ok=not_found_ok,
wrap_xmodule_display=wrap_xmodule_display)
except ItemNotFoundError: except ItemNotFoundError:
if not not_found_ok: if not not_found_ok:
log.exception("Error in get_module") log.exception("Error in get_module")
...@@ -165,6 +156,14 @@ def get_module_for_descriptor(user, request, descriptor, student_module_cache, c ...@@ -165,6 +156,14 @@ def get_module_for_descriptor(user, request, descriptor, student_module_cache, c
return None return None
def get_module_for_descriptor(user, request, descriptor, student_module_cache, course_id,
position=None, not_found_ok=False, wrap_xmodule_display=True):
"""
Actually implement get_module. See docstring there for details.
"""
return _get_module(user, request, descriptor, student_module_cache, course_id,
position=position, wrap_xmodule_display=wrap_xmodule_display)
def _get_module(user, request, descriptor, student_module_cache, course_id, def _get_module(user, request, descriptor, student_module_cache, course_id,
position=None, wrap_xmodule_display=True): position=None, wrap_xmodule_display=True):
""" """
......
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