From 0e3cabc5f69f609e848e3ccb19e821cb881e99e3 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 28 Aug 2022 11:55:30 +0200 Subject: [PATCH] Support `attribute` parameter on `Function` schema fields. --- platypush/schemas/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platypush/schemas/__init__.py b/platypush/schemas/__init__.py index 71456ddd9..ce157319b 100644 --- a/platypush/schemas/__init__.py +++ b/platypush/schemas/__init__.py @@ -22,7 +22,9 @@ class StrippedString(fields.Function): # lgtm [py/missing-call-to-init] class Function(fields.Function): # lgtm [py/missing-call-to-init] - def _get_attr(self, obj, attr: str): + def _get_attr(self, obj, attr: str, _recursive=True): + if self.attribute and _recursive: + return self._get_attr(obj, self.attribute, False) if hasattr(obj, attr): return getattr(obj, attr) elif hasattr(obj, 'get'):