From 2b8c630500f8a65566cf5ccf76b5215add840e54 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Mon, 16 Dec 2019 17:57:37 +0900 Subject: [PATCH] ZODB Components: When migrating FS Mixin, set the ZODB Component reference to the class name (like Interfaces). --- product/ERP5/Document/BusinessTemplate.py | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index b270bf2f32..4b18bafca1 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -6633,6 +6633,33 @@ Business Template is a set of definitions, such as skins, portal types and categ continue subsubmodule_name = interface_class_name + # TODO-arnau: Refactor with 'Interface Component' + elif component_portal_type == 'Mixin Component': + try: + mixin_module = __import__(source_reference, {}, {}, source_reference) + except ImportError, e: + LOG("BusinessTemplate", WARNING, + "Skipping %s: Cannot be imported (%s)" % (filepath, e)) + continue + + mixin_class_name = None + for _, m in inspect.getmembers(mixin_module, inspect.isclass): + if (m.__name__.endswith('Mixin') and + # Local definition only + m.__module__ == mixin_module.__name__): + if mixin_class_name is not None: + # Do not try to be clever, just let the developer fix the problem + LOG("BusinessTemplate", WARNING, + "Skipping %s: More than one Mixin defined" % filepath) + mixin_class_name = None + break + else: + mixin_class_name = m.__name__ + + if mixin_class_name is None: + continue + + subsubmodule_name = mixin_class_name obj = __newTempComponent(portal_type=subsubmodule_portal_type, reference=subsubmodule_name, -- 2.30.9