Cement core extensions module.

class cement.core.extension.CementExtensionHandler(**kw)

Bases: cement.core.handler.CementBaseHandler

class Meta

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


The interface that this class implements.

alias of IExtension

label = 'cement'

The string identifier of the handler.


Returns list of loaded extensions.


Given an extension module name, load or in other-words ‘import’ the extension.

Parameters:ext_module (str) – The extension module name. For example: ‘cement.ext.ext_logging’.

Given a list of extension modules, iterate over the list and pass individually to self.load_extension().

Parameters:ext_list (list) – A list of extension modules.
class cement.core.extension.IExtension

Bases: cement.core.interface.Interface

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

Implementations do not subclass from interfaces.


from cement.core import extension

class MyExtensionHandler(object):
    class Meta:
        interface = extension.IExtension
        label = 'my_extension_handler'
class IMeta

Interface meta-data.

label = 'extension'

The string identifier of the interface.


The interface validator function.


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.

Load an extension whose module is ‘ext_module’. For example, ‘cement.ext.ext_configobj’.

Parameters:ext_module (str) – The name of the extension to load.

Load all extensions from ext_list.

Parameters:ext_list (list) – A list of extension modules to load. For example: ['cement.ext.ext_configobj', 'cement.ext.ext_logging']
cement.core.extension.extension_validator(klass, obj)

Validates an handler implementation against the IExtension interface.