From 5410e161f97b7ab12937b49aa688e2236ae52a14 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 25 Sep 2012 09:48:54 -0400 Subject: [PATCH] Switch template definitions to yaml, so that they can have multiline strings --- common/lib/xmodule/xmodule/capa_module.py | 2 ++ common/lib/xmodule/xmodule/templates/default/empty.json | 5 ----- common/lib/xmodule/xmodule/templates/default/empty.yaml | 5 +++++ .../lib/xmodule/xmodule/templates/problem/multiline.yaml | 7 +++++++ common/lib/xmodule/xmodule/x_module.py | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) delete mode 100644 common/lib/xmodule/xmodule/templates/default/empty.json create mode 100644 common/lib/xmodule/xmodule/templates/default/empty.yaml create mode 100644 common/lib/xmodule/xmodule/templates/problem/multiline.yaml diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 052f4eefe7..ae7ebc3b78 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -644,6 +644,8 @@ class CapaDescriptor(RawDescriptor): # actually use type and points? metadata_attributes = RawDescriptor.metadata_attributes + ('type', 'points') + template_dir_name = 'problem' + # VS[compat] # TODO (cpennington): Delete this method once all fall 2012 course are being # edited in the cms diff --git a/common/lib/xmodule/xmodule/templates/default/empty.json b/common/lib/xmodule/xmodule/templates/default/empty.json deleted file mode 100644 index be5d368dbc..0000000000 --- a/common/lib/xmodule/xmodule/templates/default/empty.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "metadata": { "display_name": "Empty" }, - "data": "", - "children": [] -} diff --git a/common/lib/xmodule/xmodule/templates/default/empty.yaml b/common/lib/xmodule/xmodule/templates/default/empty.yaml new file mode 100644 index 0000000000..a2fb2b5832 --- /dev/null +++ b/common/lib/xmodule/xmodule/templates/default/empty.yaml @@ -0,0 +1,5 @@ +--- +metadata: + display_name: Empty +data: "" +children: [] diff --git a/common/lib/xmodule/xmodule/templates/problem/multiline.yaml b/common/lib/xmodule/xmodule/templates/problem/multiline.yaml new file mode 100644 index 0000000000..94df320bfe --- /dev/null +++ b/common/lib/xmodule/xmodule/templates/problem/multiline.yaml @@ -0,0 +1,7 @@ +--- +metadata: + display_name: Multiline XML +data: | + + +children: [] diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index f7560c7a55..cf08a0b7b2 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -1,6 +1,6 @@ import logging import pkg_resources -import json +import yaml import os from functools import partial @@ -352,7 +352,7 @@ class ResourceTemplates(object): for template_file in resource_listdir(__name__, dirname): template_content = resource_string(__name__, os.path.join(dirname, template_file)) - template = json.loads(template_content) + template = yaml.load(template_content) templates.append(Template(**template)) return templates