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
  • Notable Features and Changes
  • Better Documentation
  • Simplified API Naming Conventions and Usage
  • Developer Tools CLI
  • Clearer Interface Definition and Implementation
  • Docker / Docker Compose Support
  • Environment Variable Overrides
  • New Interfaces
  • New Extensions
  1. Release Information

What's New!

Overview of notable features and major changes in the latest release.

PreviousRelease InformationNextUpgrading

Last updated 6 years ago

Notable Features and Changes

Better Documentation

A lot of time and effort has gone into revamping the developer documentation, which includes:

  • Separation of Developer Guide (this) and

  • Complete and to get started building your first application

  • List of used throughout the framework and documentation

  • Thorough guide of all

Simplified API Naming Conventions and Usage

The naming conventions and library paths in Cement 2 were laborious to type and remember. Now all modules/methods/etc are importable from cement namespace directly, and the naming is simplified (ex: CementApp is now App, CementHandler is now Handler, etc).

from cement import App, Controller, ex

class Base(Controller):
    class Meta:
        label = 'base'

    @ex(help='this is a command')
    def cmd1(self):
        print('Inside Base.cmd1()')

class MyApp(App):
    class Meta:
        label = 'myapp'
        handlers = [Base]

Developer Tools CLI

$ cement generate project ./myapp
INFO: Generating cement project in ./myapp/

$ cement generate plugin ./myapp/plugins/
INFO: Generating cement plugin in ./myapp/plugins/

$ cement generate extension ./myapp/ext/
INFO: Generating cement extension in ./myapp/ext/

$ cement generate script .
INFO: Generating cement script in .

Clearer Interface Definition and Implementation

In Cement 2, the design of the interface and handler system was not easy to follow for new developers to the framework. It was also loosely modeled after ZopeInterface, and that may have lead to some odd naming conventions (IMeta, IMyInterface, etc), and an implementation that just felt weird.

Docker / Docker Compose Support

Cement now includes a fully functioning docker setup out-of-the-box for local development of the framework that includes all dependencies, and dependency services like Redis, Memcached, etc.

Getting up and running is as simple as running the following:

$ make dev

|> cement <| src #

This drops you into a shell within a docker container, and environment so that everything required to dev, and test is ready to roll:

|> cement <| src # make test

|> cement <| src # make docs

See the Makefile for more common development tasks (for framework development).

Environment Variable Overrides

Cement now supports the ability to override all config object settings via their associated environment variables. For example:

from cement import App, init_defaults

CONFIG = init_defaults('myapp')
CONFIG['myapp']['foo'] = 'bar'

class MyApp(App):
    class Meta:
        label = 'myapp'
        config_defaults = CONFIG

with MyApp() as app:
    app.run()
    foo = app.config.get('myapp', 'foo')
    print('Foo => %s' % foo)
$ python myapp.py
Foo => bar

$ export MYAPP_FOO='not-bar'

$ python myapp.py
Foo => not-bar

Environment variables are logically mapped to configuration settings based on their config keys and are prefixed with MYAPP_ (based on the label of the app). So:

  • config['myapp']['foo'] => $MYAPP_FOO

  • config['some_section']['foo'] => $MYAPP_SOME_SECTION_FOO

New Interfaces

Interface

Description

Rendering of template data (content, files, etc). Existing output handler extensions were also updated to include an associated template handler (MustacheTemplateHandler, Jinja2TemplateHandler, etc).

New Extensions

Extension

Description

Used primarily in development as a replacement for standard print(), allowing the developer to honor framework features like pre_render and post_render hooks.

Adds the ability to easily obfuscate sensitive data from rendered output (think IP addresses, credit card numbers, etc)

Adds the ability for application developers to add a generate controller to their application, and include any number of source templates to generate from. Think myapp generate plugin for third party developers to create plugins for your application from a fully-functional working template.

The allow developers to quickly generate projects, plugins, extensions, and scripts:

Interfaces are now defined using the standard library's module per the , moving the framework away from oddities and more toward common Python standards.

API Reference
framework overview
beginner tutorial
terminology
builtin extensions
Cement Developer Tools
Abstract Base Class
request of the community
Template
Print
Scrub
Generate