Note
To learn how to implement your own renderer, please analyze the source code of the classes defined in this module.
Note
To learn how to register your own renderer (to make it usable with in your n6sdk-based application), please consult the n6sdk.pyramid_commons.register_stream_renderer() documentation.
Bases: object
The base class for renderers.
Bases: n6sdk.pyramid_commons.renderers.BaseStreamRenderer
The class of the renderer registered as the json one.
Bases: n6sdk.pyramid_commons.renderers.BaseStreamRenderer
The class of the renderer registered as the sjson one.
Get a copy of the given dictionary with empty-or-None items removed recursively.
(A helper function used by the StreamRenderer_json and StreamRenderer_sjson renderers.)
Note
Values equal to 0 (including False) are not removed. Other false values – such as empty sequences (including strings) or None – are removed.
>>> d = {
... 'a': 'A', 'b': '', 'c': [], 'd': (), 'e': {}, 'f': [''], 'g': ['x'],
... 'h': {
... 'a': 'A', 'b': '', 'c': [], 'd': (), 'e': {}, 'f': [''], 'g': ['x'],
... },
... 'i': ['A', '', 0, [], (), {}, [None], [0.0], ['x']],
... 'j': ['', [{}], ([{}]), {'x': ()}, ['']],
... 'k': [None],
... 'l': {'x': None},
... 'm': None,
... 'x': [0],
... 'y': {'x': False},
... 'z': 0,
... }
>>> d2 = dict_with_nulls_removed(d)
>>> d2 == {
... 'a': 'A', 'g': ['x'],
... 'h': {'a': 'A', 'g': ['x']},
... 'i': ['A', 0, [0.0], ['x']],
... 'x': [0],
... 'y': {'x': False},
... 'z': 0,
... }
True
>>> dict_with_nulls_removed({})
{}