# `cement.core.extension`

Cement core extensions module.

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

  Bases: `cement.core.handler.CementBaseHandler`

  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 `IExtension`

    `label` = 'cement'

      The string identifier of the handler.

  `get_loaded_extensions`()

    Returns list of loaded extensions.

  `load_extension`(ext_module)

    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’.
    Raises: | cement.core.exc.FrameworkError

  `load_extensions`(ext_list)

    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.

  Usage:

      from cement.core import extension

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

  class `IMeta`

    Bases: `object`

    Interface meta-data.

    `label` = 'extension'

      The string identifier of the interface.

    `validator`(obj)

      The interface validator function.

  `_setup`()

    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.
    Returns: | None

  `load_extension`(ext_module)

    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_extensions`(ext_list)

    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.