cement.core.interface

Cement core interface module.

class cement.core.interface.Interface(**kw)[source]

Bases: abc.ABC, cement.core.meta.MetaMixin

Base interface class that all Cement Interfaces should subclass from.

class Meta[source]

Bases: object

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

interface = NotImplemented

The string identifier of this interface.

_validate()[source]

Perform any validation to ensure proper data, meta-data, etc.

class cement.core.interface.InterfaceManager(app)[source]

Bases: object

Manages the interface system to define, get, list interfaces with the Cement Framework.

define(ibc)[source]

Define an ibc (interface base class).

Parameters:

ibc (Interface) – The abstract base class that defines the interface

Raises:

Example

app.interface.define(DatabaseInterface)
defined(interface)[source]

Test whether interface is defined.

Parameters:interface (str) – The label of the interface (I.e. log, config, output, etc).
Returns:True if the interface is defined, False otherwise
Return type:bool

Example

app.interface.defined('log')
get(interface, fallback=None, **kwargs)[source]

Get an interface class.

Parameters:
  • interface (str) – The interface label (i.e. output)
  • fallback (Handler) – A fallback value to return if interface doesn’t exist.
Returns:

An uninstantiated interface class

Return type:

Interface

Raises:

cement.core.exc.InterfaceError – If the interface does not exist.

Example

i = app.interface.get('output')
list()[source]

Return a list of defined interfaces.

Returns:Interface labels.
Return type:list

Example

app.interface.list()