File: example_app.rst

package info (click to toggle)
paperwork 2.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 166,660 kB
  • sloc: python: 44,775; makefile: 992; sh: 625; xml: 135
file content (32 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Calling Code Example
====================

.. code-block:: python

   import openpaperwork_core


   core = openpaperwork_core.Core()

   # Load mandatory plugins
   core.load("openpaperwork_plugin_a")
   core.load("mandatory_plugin_a")
   core.load("mandatory_plugin_b")

   # `init()` will load dependencies and call method `init()` on all the plugins
   # You can safely call `core.init()` many times
   core.init()

   # Load plugins requested by your user if any.
   # You can used previously loaded to get the plugin to load if you want.
   # For instance, you can load and initialize `openpaperwork_core.config`
   # and then use it to get a plugin list from a configuration file.
   core.load(...)

   core.init()

   nb_called = core.call_all('some_method_a', "random_argument")
   assert(nb_called > 0)

   return_value = core.call_success('some_method_a', "random_argument")
   assert(return_value is not None)