cement.core.interface
Cement core interface module.
- class cement.core.interface.Interface(**kw: Any)[source]
-
Base interface class that all Cement Interfaces should subclass from.
- class cement.core.interface.InterfaceManager(app: App)[source]
Bases:
objectManages the interface system to define, get, list interfaces with the Cement Framework.
- define(ibc: Type[Interface]) None[source]
Define an
ibc(interface base class).- Parameters:
ibc (Interface) – The abstract base class that defines the interface
- Raises:
cement.core.exc.InterfaceError – If the interface label is already
defined –
Example
app.interface.define(DatabaseInterface)
- defined(interface: str) bool[source]
Test whether
interfaceis defined.- Parameters:
interface (str) – The label of the interface (I.e.
log,config,output, etc).- Returns:
Trueif the interface is defined,Falseotherwise- Return type:
Example
app.interface.defined('log')
- get(interface: str, fallback: Type[Interface] | None = None, **kwargs: Any) Type[Interface][source]
Get an interface class.
- Parameters:
- Returns:
An uninstantiated interface class
- Return type:
- Raises:
cement.core.exc.InterfaceError – If the
interfacedoes not exist.
Example
i = app.interface.get('output')