Files
edx-platform/common/lib/xmodule/xmodule/templates.py
Calen Pennington 417fe21d05 Enable pure XBlocks, but behind a feature flag
[LMS-226]
[LMS-2013]
2014-01-10 11:40:03 -05:00

32 lines
915 B
Python

"""
This module handles loading xmodule templates
These templates are used by the CMS to provide content that overrides xmodule defaults for
samples.
``Template``s are defined in x_module. They contain 2 attributes:
:metadata: A dictionary with the template metadata
:data: A JSON value that defines the template content
"""
# should this move to cms since it's really only for module crud?
import logging
from collections import defaultdict
from xblock.core import XBlock
log = logging.getLogger(__name__)
def all_templates():
"""
Returns all templates for enabled modules, grouped by descriptor type
"""
# TODO use memcache to memoize w/ expiration
templates = defaultdict(list)
for category, descriptor in XBlock.load_classes():
if not hasattr(descriptor, 'templates'):
continue
templates[category] = descriptor.templates()
return templates