Changed yield_module_descendents to be stack-based, so it plays nicer with the profiler.

This commit is contained in:
Bridger Maxwell
2012-08-07 16:16:31 -04:00
parent 1f34cf33fa
commit ec04b0cb13

View File

@@ -12,10 +12,12 @@ from models import StudentModule
log = logging.getLogger("mitx.courseware")
def yield_module_descendents(module):
for child in module.get_display_items():
yield child
for module in yield_module_descendents(child):
yield module
stack = module.get_display_items()
while len(stack) > 0:
next_module = stack.pop()
stack.extend( next_module.get_display_items() )
yield next_module
def grade(student, request, course, student_module_cache=None):
"""