Commit 70fa412f authored by Jerome Flesch's avatar Jerome Flesch

Core: Add README

Signed-off-by: Jerome Flesch's avatarJerome Flesch <>
parent db1c712e
# OpenPaperwork Core
Manages Plugins, Callbacks and Interfaces.
A plugin is a Python module providing a class `Plugin`.
Callbacks are all the methods provided by the class `Plugin` (with some
exceptions, like methods starting with `_`).
Interfaces are simply conventions: Plugins pretending to implement some
interfaces must implement the corresponding methods. No check is done to ensure
they do.
## Example
### Plugin
import openpaperwork_core
class Plugin(openpaperwork_core.PluginBase):
# indicates that users should be able to disable/enable this plugin in
# the UI (if available/possible in the application)
def __init__(self):
# do something, but the least possible
# cannot rely on dependencies here.
def get_implementated_interfaces(self):
return ['interface_name_toto', 'interface_name_tutu']
def get_deps(self):
return {
'plugins': [
'interfaces': [
def init(self):
# all the dependnecies have loaded and initialized.
# we can safely rely on them here.
def some_method_a(self, arg_a):
# do something
### Application using the core
import openpaperwork_core
core = openpaperwork_core.Core()
# load mandatory plugins
# load plugins requested by your user if any
# init() will load dependencies and call method `init()` on all the plugins
# call_all() will call all the methods with the specified name. Return values
# are ignored. You have to pass a callback as argument if you want to get
# result from all callbacks.
core.call_all('some_method_a', "random_argument")
# call_one() will call one of the methods with the specified name.
# It is assumed that only one callback has this name. Return value of the
# callback is returned as it.
return_value = core.call_one('some_method_a', "random_argument")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment