From 07cae43484911ddf87b87d7d3399f7b09378f8fe Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 5 Sep 2012 14:35:44 +0200 Subject: Fixed metadata serialization of Numbers and DNs There were following problems: 1. DNs and Decimals weren't properly serialized. Serialization output was object with empty __base64__ attribute. It was fixed by converting them to string. 2. numberical values equal to 0 were excluded from metadata. It broke many of minvalue checks in Web UI. Now excluding only None and False values as initally intended. https://fedorahosted.org/freeipa/ticket/3052 --- ipalib/util.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ipalib/util.py') diff --git a/ipalib/util.py b/ipalib/util.py index 44f08e7f..155d9329 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -26,6 +26,7 @@ import imp import time import socket import re +import decimal from types import NoneType from weakref import WeakKeyDictionary from dns import resolver, rdatatype @@ -46,6 +47,8 @@ def json_serialize(obj): return obj if isinstance(obj, str): return obj.decode('utf-8') + if isinstance(obj, (decimal.Decimal, DN)): + return str(obj) if not callable(getattr(obj, '__json__', None)): # raise TypeError('%r is not JSON serializable') return '' -- cgit