From d888fe240c11ff41f529250b72fdb7ce0811d79d Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Thu, 4 Jun 2020 18:26:45 +0700 Subject: [PATCH] Remove misplaced constants describing worklow task types * These constants have nothing to do with this project. They should be in the 'mistral' repo. * Minor style changes. Change-Id: Ia3f50388638d68bbcc5e2e9e424ddb9dd65b26eb --- mistral_lib/actions/context.py | 5 +++++ mistral_lib/actions/types.py | 1 + mistral_lib/utils/__init__.py | 8 ++------ mistral_lib/utils/inspect_utils.py | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mistral_lib/actions/context.py b/mistral_lib/actions/context.py index 65cf86a..38aeadb 100644 --- a/mistral_lib/actions/context.py +++ b/mistral_lib/actions/context.py @@ -35,9 +35,12 @@ class ActionContext(serialization.MistralSerializable): "redelivered", "region_name", "service_catalog", "trust_id", "user_name" ] + if name in deprecated: self._deprecation_warning(name) + return getattr(self.security, name) + return super(ActionContext, self).__getattribute__(name) @@ -75,6 +78,7 @@ class ExecutionContext(object): if task_id is not None: self.task_execution_id = task_id + self._deprecate_task_id_warning() def _deprecate_task_id_warning(self): @@ -87,6 +91,7 @@ class ExecutionContext(object): @property def task_id(self): self._deprecate_task_id_warning() + return self.task_execution_id diff --git a/mistral_lib/actions/types.py b/mistral_lib/actions/types.py index f9ae568..e50e46d 100644 --- a/mistral_lib/actions/types.py +++ b/mistral_lib/actions/types.py @@ -35,6 +35,7 @@ class Result(serialization.MistralSerializable): _data = utils.mask_data(self.data) _error = utils.mask_data(self.error) _cancel = utils.mask_data(self.cancel) + return 'Result [data=%s, error=%s, cancel=%s]' % ( utils.cut(_data), utils.cut(_error), str(_cancel) ) diff --git a/mistral_lib/utils/__init__.py b/mistral_lib/utils/__init__.py index 56f88b4..500e64b 100644 --- a/mistral_lib/utils/__init__.py +++ b/mistral_lib/utils/__init__.py @@ -37,15 +37,10 @@ from oslo_utils import uuidutils import pkg_resources as pkg import random + # Thread local storage. _th_loc_storage = threading.local() -# TODO(rakhmerov): these two constants are misplaced. Utility methods -# should not be Mistral specific. They should be generic enough so to -# be moved to any other project w/o changes. -ACTION_TASK_TYPE = 'ACTION' -WORKFLOW_TASK_TYPE = 'WORKFLOW' - def generate_unicode_uuid(): return uuidutils.generate_uuid() @@ -96,6 +91,7 @@ def set_thread_local(var_name, val): if val is not None: gl_storage = _get_greenlet_local_storage() + if not gl_storage: gl_storage = _th_loc_storage.greenlet_locals[ corolocal.get_ident()] = {} diff --git a/mistral_lib/utils/inspect_utils.py b/mistral_lib/utils/inspect_utils.py index 5e223d2..2121bc8 100644 --- a/mistral_lib/utils/inspect_utils.py +++ b/mistral_lib/utils/inspect_utils.py @@ -26,6 +26,7 @@ def get_public_fields(obj): for attribute_str in public_attributes: attr = getattr(obj, attribute_str) + is_field = not (inspect.isbuiltin(attr) or inspect.isfunction(attr) or inspect.ismethod(attr) or