Don't output Unset values

This commit is contained in:
Christophe de Vienne 2011-11-28 18:32:03 +01:00
parent 68890490d8
commit d24ea244a6

View File

@ -7,6 +7,7 @@ import decimal
from simplegeneric import generic
from wsme.protocols.rest import RestProtocol
from wsme.types import Unset
import wsme.types
try:
@ -34,7 +35,9 @@ def tojson(datatype, value):
if wsme.types.iscomplex(datatype):
d = dict()
for attr in wsme.types.list_attributes(datatype):
d[attr.name] = tojson(attr.datatype, getattr(value, attr.key))
attr_value = getattr(value, attr.key)
if attr_value is not Unset:
d[attr.name] = tojson(attr.datatype, attr_value)
return d
elif wsme.types.isusertype(datatype):
return tojson(datatype.basetype, datatype.tobasetype(value))