The Print Extension adds the
PrintOutputHandler
and PrintDictOutputHandler
to render output in pure text. It is mostly intended for development, but also supports the additional app.print()
extended function which can be used in place of the standard print()
so that apps can continue to utilize features of the framework consistently (such as honoring pre_render
and post_render
hooks, etc).Documentation References:
API References:
- No external dependencies
This extension does not support any application level configuration settings or meta options.
Example: Using Print Output Handler
from cement import App
class MyApp(App):
class Meta:
label = 'myapp'
extensions = ['print']
with MyApp() as app:
app.run()
app.print('This is an output message')
Alternatively, you can use the
print_dict
output handler that can be useful in development as it simply just prints out a string representation of the data dict.Example: Using Print Dict Output Handler
from cement import App
class MyApp(App):
class Meta:
label = 'myapp'
extensions = ['print_dict']
output_handler = 'print_dict'
with MyApp() as app:
app.run()
data = {
'foo' : 'bar',
}
app.render(data)
Last modified 5yr ago