use same getattr pattern in the XModule constructor that exists in the XModuleDescriptor

This commit is contained in:
Chris Dodge
2013-08-15 16:24:54 -04:00
parent 03608a8931
commit 71de34fca3

View File

@@ -173,11 +173,11 @@ class XModule(XModuleFields, HTMLSnippet, XBlock):
# don't need to set category as it will automatically get from descriptor
elif 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()