cement.ext.ext_json
Cement json extension module.
- class cement.ext.ext_json.JsonConfigHandler(*args: Any, **kw: Any)[source]
Bases:
ConfigParserConfigHandler
This class implements the Config Handler interface, and provides the same functionality of ConfigParserConfigHandler but with JSON configuration files.
- class Meta[source]
Bases:
Meta
Handler meta-data.
- json_module = 'json'
Backend JSON library module to use (json, ujson).
- class cement.ext.ext_json.JsonOutputHandler(*args: Any, **kw: Any)[source]
Bases:
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:
Meta
Handler meta-data
- json_module = 'json'
Backend JSON library module to use (json, ujson)
- _setup(app: App) None [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.
- cement.ext.ext_json.suppress_output_after_render(app: App, out_text: str) None [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.