From e9358f0e4ec79874e5859a192a3588199c8cb6a5 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 24 Sep 2012 09:05:31 -0400 Subject: [PATCH] Make ErrorDescriptor continue to use the interface for __init__ that XModuleDescriptor uses, while providing a helper function for constructing from a different set of arguments --- common/lib/xmodule/xmodule/error_module.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/error_module.py b/common/lib/xmodule/xmodule/error_module.py index 4a4b55e652..c95e734258 100644 --- a/common/lib/xmodule/xmodule/error_module.py +++ b/common/lib/xmodule/xmodule/error_module.py @@ -51,7 +51,8 @@ class ErrorDescriptor(EditingDescriptor): """ module_class = ErrorModule - def __init__(self, system, contents, error_msg, org=None, course=None): + @classmethod + def _construct(self, system, contents, error_msg, org=None, course=None): # Pick a unique url_name -- the sha1 hash of the contents. # NOTE: We could try to pull out the url_name of the errored descriptor, @@ -82,7 +83,7 @@ class ErrorDescriptor(EditingDescriptor): @classmethod def from_descriptor(cls, descriptor, error_msg='Error not available'): - return cls( + return cls._construct( descriptor.system, json.dumps({ 'definition': descriptor.definition, @@ -118,7 +119,7 @@ class ErrorDescriptor(EditingDescriptor): # Save the error to display later--overrides other problems error_msg = exc_info_to_str(sys.exc_info()) - return cls(system, xml_data, error_msg, org=org, course=course) + return cls._construct(system, xml_data, error_msg, org=org, course=course) def export_to_xml(self, resource_fs): '''