LogoLogo
Official SiteAPI Reference
stable/3.0
stable/3.0
  • Cement Developer Guide
  • Release Information
    • What's New!
    • Upgrading
    • ChangeLog
    • Deprecations
  • Getting Started
    • Installation
    • Developer Tools
    • Framework Overview
    • Beginner Tutorial
      • Part 1: Creating Your First Project
      • Part 2: Adding Features
      • Part 3: Extending a Project
      • Part 4: Making Everything Legit
  • Core Foundation
    • Interfaces and Handlers
    • Hooks
    • Configuration Settings
    • Arguments
    • Logging
    • Controllers
    • Output Rendering
    • Caching
    • Mail Messaging
    • Framework Extensions
    • Application Plugins
    • Templating
  • Utilities
    • Filesystem
    • Shell
    • Miscellaneous
  • Extensions
    • Alarm
    • Argparse
    • Colorlog
    • ConfigParser
    • Daemon
    • Dummy
    • Generate
    • Jinja2
    • Json
    • Logging
    • Memcached
    • Mustache
    • Plugin
    • Print
    • Redis
    • Scrub
    • SMTP
    • Tabulate
    • Yaml
    • Watchdog
  • Additional Topics
    • Extending The App Object
    • Unit Testing
    • Cleanup
    • Signal Handling
    • Pipenv
    • Autocomplete
    • Profiling with cProfile
    • Debugging with VSCode
  • Environment Variables
  • Terminology
  • Contributing
  • Privacy Policy
Powered by GitBook
On this page
  • Introduction
  • Requirements
  • Configuration
  • Usage
  1. Extensions

Print

PreviousPluginNextRedis

Last updated 6 years ago

Introduction

The Print Extension adds the and 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 and hooks, etc).

Documentation References:

API References:

Requirements

  • No external dependencies

Configuration

This extension does not support any application level configuration settings or meta options.

Usage

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.

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)
PrintOutputHandler
PrintDictOutputHandler
Output Rendering
Cement Print Extension
pre_render
post_render