From 1f5260cfb7516822d593d6103b7aa09ae9f86b84 Mon Sep 17 00:00:00 2001 From: max-orlov Date: Tue, 28 Nov 2017 17:24:31 +0200 Subject: [PATCH] ARIA-417 Encoding models to json is too strict --- aria/modeling/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py index 1b6b3753..27d261db 100644 --- a/aria/modeling/utils.py +++ b/aria/modeling/utils.py @@ -35,15 +35,14 @@ def __init__(self, *args, **kwargs): # Just here to make sure Sphinx doesn't grab the base constructor's docstring super(ModelJSONEncoder, self).__init__(*args, **kwargs) - def default(self, o): # pylint: disable=method-hidden - from .mixins import ModelMixin - if isinstance(o, ModelMixin): + def default(self, o): # pylint: disable=method-hidden + try: if hasattr(o, 'value'): dict_to_return = o.to_dict(fields=('value',)) return dict_to_return['value'] else: return o.to_dict() - else: + except AttributeError: return JSONEncoder.default(self, o)