cement.core.output

Cement core output module.

class cement.core.output.CementOutputHandler(*args, **kw)

Bases: cement.core.handler.CementBaseHandler

Base class that all Output Handlers should sub-class from.

class Meta

Bases: object

Handler meta-data (can be passed as keyword arguments to the parent class).

interface

The interface that this class implements.

alias of IOutput

label = None

The string identifier of this handler.

class cement.core.output.IOutput

Bases: cement.core.interface.Interface

This class defines the Output Handler Interface. Classes that implement this handler must provide the methods and attributes defined below.

Implementations do not subclass from interfaces.

Usage:

from cement.core import output

class MyOutputHandler(object):
    class Meta:
        interface = output.IOutput
        label = 'my_output_handler'
    ...
class IMeta

Bases: object

Interface meta-data.

label = 'output'

The string identifier of the interface.

validator(klass, obj)

The interface validator function.

IOutput._setup(app_obj)

The _setup function is 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_obj – The application object.
IOutput.render(data_dict, *args, **kwargs)

Render the data_dict into output in some fashion. This function must access both *args and **kwargs to allow an application to mix output handlers that support different features.

Parameters:data_dict – The dictionary whose data we need to render into output.
Returns:string or unicode string or None
class cement.core.output.TemplateOutputHandler(*args, **kw)

Bases: cement.core.output.CementOutputHandler

Base class for template base output handlers.

load_template(template_path)

Loads a template file first from self.app._meta.template_dirs and secondly from self.app._meta.template_module. The template_dirs have presedence. :param template_path: The secondary path of the template after

either template_module or template_dirs prefix (set via CementApp.Meta)
Returns:The content of the template (str)
Raises:FrameworkError if the template does not exist in either the template_module or template_dirs.
load_template_with_location(template_path)

Loads a template file first from self.app._meta.template_dirs and secondly from self.app._meta.template_module. The template_dirs have presedence.

Parameters:template_path – The secondary path of the template after either template_module or template_dirs prefix (set via CementApp.Meta)
Returns:A tuple that includes the content of the template (str), the type of template (str which is one of: directory, or module), and the path (str) of the directory or module)
Raises:FrameworkError if the template does not exist in either the template_module or template_dirs.
cement.core.output.output_validator(klass, obj)

Validates an handler implementation against the IOutput interface.