Commit ab0b7910 by Bridger Maxwell

Added caching for processed course.xml

--HG--
branch : dormsbee_performance
parent 6ad93db8
......@@ -170,15 +170,24 @@ def course_xml_process(tree):
def course_file(user):
''' Given a user, return course.xml
'''
# TODO: Cache.
filename = user.profile_cache.courseware # UserProfile.objects.get(user=user).courseware
groups = user_groups(user)
options = {'dev_content':settings.DEV_CONTENT,
'groups' : groups}
cache_key = filename + "_processed?dev_content:" + str(options['dev_content']) + "&groups:" + str(sorted(groups))
tree_string = cache.get(cache_key)
if not tree_string:
tree = course_xml_process(etree.XML(render_to_string(filename, options, namespace = 'course')))
tree_string = etree.tostring(tree)
cache.set(cache_key, tree_string, 60)
else:
tree = etree.XML(tree_string)
return tree
def section_file(user, section):
......
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