cement.ext.ext_json
¶
Cement json extension module.
-
class
cement.ext.ext_json.
JsonConfigHandler
(*args, **kw)[source]¶ Bases:
cement.ext.ext_configparser.ConfigParserConfigHandler
This class implements the Config Handler interface, and provides the same functionality of ConfigParserConfigHandler but with JSON configuration files.
-
class
Meta
[source]¶ Bases:
object
Handler meta-data.
-
json_module
= 'json'¶ Backend JSON library module to use (json, ujson).
-
-
class
-
class
cement.ext.ext_json.
JsonOutputHandler
(*args, **kw)[source]¶ Bases:
cement.core.output.OutputHandler
This class implements the Output Handler interface. It provides JSON output from a data dictionary using the json module of the standard library. Please see the developer documentation on Output Handling.
This handler forces Cement to suppress console output until
app.render
is called (keeping the output pure JSON). If troubleshooting issues, you will need to pass the--debug
option in order to unsuppress output and see what’s happening.-
class
Meta
[source]¶ Bases:
object
Handler meta-data
-
json_module
= 'json'¶ Backend JSON library module to use (json, ujson)
-
label
= 'json'¶ The string identifier of this handler.
-
overridable
= False¶ Whether or not to include
json
as an available choice to override theoutput_handler
via command line options.
-
-
_setup
(app)[source]¶ Called during application initialization and must
setup
the handler object making it ready for the framework or the application to make further calls to it.Parameters: app (instance) – The application object.
-
render
(data_dict, template=None, **kw)[source]¶ Take a data dictionary and render it as Json output. Note that the template option is received here per the interface, however this handler just ignores it. Additional keyword arguments passed to
json.dumps()
.Parameters: data_dict (dict) – The data dictionary to render. Keyword Arguments: template – This option is completely ignored. Returns: A JSON encoded string. Return type: str
-
class
-
cement.ext.ext_json.
suppress_output_after_render
(app, out_text)[source]¶ This is a
post_render
hook that suppresses console output again after rendering, only if theJsonOutputHandler
is triggered via command line.Parameters: app – The application object.