You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.7 KiB

Build plugins

A plugin is a basic python function that takes positional arguments i.e one being request and the other config. We allow the function to have access to the request object (if data were submitted) and to QCMS configuration if any configuration data is needed.

<div class="source-code editor border">
    <span class="code-comment"># saving this function to www/html/_plugins/myplugins.py</span>
    <span class="code-comment">#</span>
    <span class="keyword">import</span> numpy as np
    <span class="keyword">import</span> cms 

    @cms.Plugin(mimetype="application/json", methods=["POST"])
    <span class="keyword">def</span> demo(**_args):
        req = _args['request']
        conf= _args['config']
        <span class="keyword">return</span> {"name":"foo","age":np.random.randint(0,100)}
</div>

Register Plugin

Once a plugin is build it needs to be registered, in order to allow the function be made available to calling code (JS/HTML5)

$ qcms plugin-register qcms-manifest.json myplugins.py --import demo

Calling the registered function as an API. The example uses curl

Limitations

QCMS lowers the barrier to entry and makes the following tradeoffs to deliver an optimal solution:

    Plugins are basic python function that need to be registered with QCMS instance/site
    We delegate access control (read/write) to web content to a cloud service provider (nextcloud for now).