From 03608a8931b3abdc0bc752c34b205a4911e36c05 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Thu, 15 Aug 2013 11:04:48 -0400 Subject: [PATCH] have XModuleDescriptor properly ensure category is set --- common/lib/xmodule/xmodule/video_module.py | 4 ---- common/lib/xmodule/xmodule/x_module.py | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py index 805ca48930..7830ff77b4 100644 --- a/common/lib/xmodule/xmodule/video_module.py +++ b/common/lib/xmodule/xmodule/video_module.py @@ -215,10 +215,6 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor self._model_data.update(model_data) del self.data - # I'm not sure how, but in some lifecycles we can loose the .category attribute - # this needs to be investigated - self.category = 'video' - @classmethod def from_xml(cls, xml_data, system, org=None, course=None): """ diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 3556f3f0f3..4b22ae9fe2 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -467,11 +467,11 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock): self.system = self.runtime if isinstance(self.location, Location): self.url_name = self.location.name - if not hasattr(self, 'category'): + if getattr(self, 'category', None) is None: self.category = self.location.category elif isinstance(self.location, BlockUsageLocator): self.url_name = self.location.usage_id - if not hasattr(self, 'category'): + if getattr(self, 'category', None) is None: raise InsufficientSpecificationError() else: raise InsufficientSpecificationError()