From 5379a9fd2b55d5ffa8e23c69c0563d44826fe8ed Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 13 Mar 2013 11:56:53 -0400 Subject: [PATCH] Make the id property available on both modules and descriptors, and make it a property, so that we aren't duplicating the location data --- common/lib/xmodule/xmodule/poll_module.py | 3 --- common/lib/xmodule/xmodule/x_module.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/poll_module.py b/common/lib/xmodule/xmodule/poll_module.py index d5dabecdca..0fb3bfb496 100644 --- a/common/lib/xmodule/xmodule/poll_module.py +++ b/common/lib/xmodule/xmodule/poll_module.py @@ -37,8 +37,6 @@ class PollFields(object): answers = List(help="Poll answers from xml", scope=Scope.content, default=[]) question = String(help="Poll question", scope=Scope.content, default='') - id = String(help="ID attribute for this module", scope=Scope.settings) - class PollModule(PollFields, XModule): """Poll Module""" @@ -193,7 +191,6 @@ class PollDescriptor(PollFields, MakoModuleDescriptor, XmlDescriptor): tag_name=self._tag_name, text=self.question) xml_object = etree.fromstring(poll_str) xml_object.set('display_name', self.display_name) - xml_object.set('id', self.id) def add_child(xml_obj, answer): child_str = '<{tag_name} id="{id}">{text}'.format( diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 9b014e10cf..02835e0d5d 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -123,15 +123,18 @@ class XModule(XModuleFields, HTMLSnippet, XBlock): model_data: A dictionary-like object that maps field names to values for those fields. ''' + self._model_data = model_data self.system = system self.location = Location(location) self.descriptor = descriptor - self.id = self.location.url() self.url_name = self.location.name self.category = self.location.category - self._model_data = model_data self._loaded_children = None + @property + def id(self): + return self.location.url() + @property def display_name_with_default(self): ''' @@ -393,6 +396,10 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock): self._child_instances = None + @property + def id(self): + return self.location.url() + @property def display_name_with_default(self): '''