cement.core.output¶
Cement core output module.
-
class
cement.core.output.CementOutputHandler(*args, **kw)¶ Bases:
cement.core.handler.CementBaseHandlerBase class that all Output Handlers should sub-class from.
-
class
cement.core.output.IOutput¶ Bases:
cement.core.interface.InterfaceThis 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:
objectInterface 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
*argsand**kwargsto 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
-
class
cement.core.output.TemplateOutputHandler(*args, **kw)¶ Bases:
cement.core.output.CementOutputHandlerBase class for template base output handlers.
-
load_template(template_path)¶ Loads a template file first from
self.app._meta.template_dirsand secondly fromself.app._meta.template_module. Thetemplate_dirshave presedence. :param template_path: The secondary path of the template aftereithertemplate_moduleortemplate_dirsprefix (set viaCementApp.Meta)Returns: The content of the template (str) Raises: FrameworkError if the template does not exist in either the template_moduleortemplate_dirs.
-
load_template_with_location(template_path)¶ Loads a template file first from
self.app._meta.template_dirsand secondly fromself.app._meta.template_module. Thetemplate_dirshave presedence.Parameters: template_path – The secondary path of the template after either template_moduleortemplate_dirsprefix (set viaCementApp.Meta)Returns: A tuple that includes the content of the template (str), the type of template (str which is one of: directory, ormodule), and thepath(str) of the directory or module)Raises: FrameworkError if the template does not exist in either the template_moduleortemplate_dirs.
-
-
cement.core.output.output_validator(klass, obj)¶ Validates an handler implementation against the IOutput interface.