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
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
-
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 fromself.app._meta.template_module
. Thetemplate_dirs
have presedence. :param template_path: The secondary path of the template aftereithertemplate_module
ortemplate_dirs
prefix (set viaCementApp.Meta
)Returns: The content of the template (str) Raises: FrameworkError if the template does not exist in either the template_module
ortemplate_dirs
.
-
load_template_with_location
(template_path)¶ Loads a template file first from
self.app._meta.template_dirs
and secondly fromself.app._meta.template_module
. Thetemplate_dirs
have presedence.Parameters: template_path – The secondary path of the template after either template_module
ortemplate_dirs
prefix (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_module
ortemplate_dirs
.
-
-
cement.core.output.
output_validator
(klass, obj)¶ Validates an handler implementation against the IOutput interface.