1
0
Fork 0

Support attribute parameter on Function schema fields.

This commit is contained in:
Fabio Manganiello 2022-08-28 11:55:30 +02:00
parent d890b6cbe8
commit 0e3cabc5f6
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -22,7 +22,9 @@ class StrippedString(fields.Function): # lgtm [py/missing-call-to-init]
class Function(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): if hasattr(obj, attr):
return getattr(obj, attr) return getattr(obj, attr)
elif hasattr(obj, 'get'): elif hasattr(obj, 'get'):