web/__init__.py
branchstable
changeset 3758 d43c9709434d
parent 3741 3864c7dfddf0
child 3777 3ef8cdb5fb1c
child 3803 414bb8439002
equal deleted inserted replaced
3756:725a2b005479 3758:d43c9709434d
    48 def json_dumps(value):
    48 def json_dumps(value):
    49     return dumps(value, cls=CubicWebJsonEncoder)
    49     return dumps(value, cls=CubicWebJsonEncoder)
    50 
    50 
    51 def jsonize(function):
    51 def jsonize(function):
    52     def newfunc(*args, **kwargs):
    52     def newfunc(*args, **kwargs):
       
    53         value = function(*args, **kwargs)
    53         try:
    54         try:
    54             value = function(*args, **kwargs)
       
    55             return json_dumps(value)
    55             return json_dumps(value)
    56         except TypeError:
    56         except TypeError:
    57             return json_dumps(repr(value))
    57             return json_dumps(repr(value))
    58     return newfunc
    58     return newfunc
    59 
    59