Don't output Unset values
This commit is contained in:
parent
68890490d8
commit
d24ea244a6
@ -7,6 +7,7 @@ import decimal
|
|||||||
from simplegeneric import generic
|
from simplegeneric import generic
|
||||||
|
|
||||||
from wsme.protocols.rest import RestProtocol
|
from wsme.protocols.rest import RestProtocol
|
||||||
|
from wsme.types import Unset
|
||||||
import wsme.types
|
import wsme.types
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -34,7 +35,9 @@ def tojson(datatype, value):
|
|||||||
if wsme.types.iscomplex(datatype):
|
if wsme.types.iscomplex(datatype):
|
||||||
d = dict()
|
d = dict()
|
||||||
for attr in wsme.types.list_attributes(datatype):
|
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
|
return d
|
||||||
elif wsme.types.isusertype(datatype):
|
elif wsme.types.isusertype(datatype):
|
||||||
return tojson(datatype.basetype, datatype.tobasetype(value))
|
return tojson(datatype.basetype, datatype.tobasetype(value))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user