Extending The App Object
For example, a plugin might extend the
apimember allowing developers to call
app.api.get(...). The application itself does not provide
app.api. However, the plugin does. As plugins are often third party, it is not possible for the plugin developer to simply sub-class the
Appclass and add the functionality because the class is already instantiated by the time plugins are loaded.
Example: Extending the App Object
from cement import App
label = 'myapp'
hooks = [
with MyApp() as app:
# call the extended object or function
Alternatively from within an extension or plugin:
$ python test.py
Extended members can be anything from instantiated objects to callables of any kind. Its use case is varied and arbitrary... but should be documented well by the developer that is extending it.