From 1efb76e6c27fb2815e639229b15208bc8c1bb4e8 Mon Sep 17 00:00:00 2001 From: Bryton Lacquement <bryton.lacquement@nexedi.com> Date: Fri, 13 Sep 2019 14:45:45 +0200 Subject: [PATCH] patches/{DynamicType,WorkflowTool}: do not use queryUtility to access tools --- product/ERP5Type/ZopePatch.py | 1 + product/ERP5Type/patches/DynamicType.py | 26 ++++++++++++++++++++++++ product/ERP5Type/patches/WorkflowTool.py | 13 ++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 product/ERP5Type/patches/DynamicType.py diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py index cf2e5e2b7b..f6ad1cb193 100644 --- a/product/ERP5Type/ZopePatch.py +++ b/product/ERP5Type/ZopePatch.py @@ -34,6 +34,7 @@ from Products.ERP5Type.patches import DCWorkflow from Products.ERP5Type.patches import Worklists from Products.ERP5Type.patches import BTreeFolder2 from Products.ERP5Type.patches import WorkflowTool +from Products.ERP5Type.patches import DynamicType from Products.ERP5Type.patches import XMLExportImport from Products.ERP5Type.patches import ppml from Products.ERP5Type.patches import Expression diff --git a/product/ERP5Type/patches/DynamicType.py b/product/ERP5Type/patches/DynamicType.py new file mode 100644 index 0000000000..6eb6a88021 --- /dev/null +++ b/product/ERP5Type/patches/DynamicType.py @@ -0,0 +1,26 @@ +############################################################################## +# +# Copyright (c) 2001 Zope Foundation and Contributors. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## + +from Products.CMFCore.DynamicType import DynamicType + +def getTypeInfo(self): + """ Get the TypeInformation object specified by the portal type. + """ + # <patch> + tool = getattr(self.getPortalObject(), "portal_types", None) + # </patch> + if tool is None: + return None + return tool.getTypeInfo(self) # Can return None. + +DynamicType.getTypeInfo = getTypeInfo diff --git a/product/ERP5Type/patches/WorkflowTool.py b/product/ERP5Type/patches/WorkflowTool.py index 366c57107a..893b4c640f 100644 --- a/product/ERP5Type/patches/WorkflowTool.py +++ b/product/ERP5Type/patches/WorkflowTool.py @@ -950,4 +950,17 @@ def canDoActionFor(self, ob, action, wf_id=None, guard_kw={}): WorkflowTool.canDoActionFor = canDoActionFor +security.declarePrivate('_listTypeInfo') +def _listTypeInfo(self): + """ List the portal types which are available. + """ + # <patch> + ttool = getattr(self.getPortalObject(), "portal_types", None) + # </patch> + if ttool is not None: + return ttool.listTypeInfo() + return () + +WorkflowTool._listTypeInfo = _listTypeInfo + InitializeClass(WorkflowTool) -- 2.30.9