From bd1a6699b4c4281a7b1796507a480ff799b27e6f Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 19 Feb 2015 18:29:24 +0000 Subject: [PATCH] allow modules to define aliases on their classes for deconstruct to use --- wagtail/wagtailcore/blocks/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailcore/blocks/__init__.py b/wagtail/wagtailcore/blocks/__init__.py index b3921c8ef..302d8583d 100644 --- a/wagtail/wagtailcore/blocks/__init__.py +++ b/wagtail/wagtailcore/blocks/__init__.py @@ -235,8 +235,15 @@ class Block(six.with_metaclass(BaseBlock, object)): "body to use migrations.\n" % (name, module_name)) + # if the module defines a DECONSTRUCT_ALIASES dictionary, see if the class has an entry in there; + # if so, use that instead of the real path + try: + path = module.DECONSTRUCT_ALIASES[self.__class__] + except (AttributeError, KeyError): + path = '%s.%s' % (module_name, name) + return ( - '%s.%s' % (module_name, name), + path, self._constructor_args[0], self._constructor_args[1], )