MedUX

OpenSource EMR

User Tools

Site Tools


en:dev:drafts:plugins

This is an old revision of the document!


Plugins

Here is a draft of how a medux plugin should be done.

There are several plugin systems that are available for python and could be possible as base:

Maybe take the “best” out of them and compose our own?

Brainstorming:

  • Cryptographic (PGP, or at least SHA2) source authentication / integrity check.
  • Plugins as ZIP files or directories
  • Plugin class where plugins can derive from, or duck typing
  • python file for metadata too, or external JSON/XML file?
    • when plugin is a python file, (unknown) code must be run to determine the metadata of the plugin. But we have to trust the plugin anyway, as python has no sandbox possibility to run code in. So BestPractice would be:
      • audit the plugin
      • mark it as trusted, sign it
      • only run plugins that are signed.
  • How should plugin load order be determined?
    • plugin dependencies, and then determination by sorting algorithm?
    • hard coded “order” property of plugins and load by this order?

Here is a sample Python code for a plugin class:

class Plugin:
    """
    Plugin class to derive from
    """
 
    # name of the plugin
    name = "My Plugin"     
 
    # Version number
    # 3-tuple: major, minor, revision
    version = (1, 0, 0)    
 
    # Description of the plugin
    # long text, translatable
    description = ""       
 
    # Category to be listed in.
    category = "Base"
 
    # Author's name of the plugin
    autor = ""
 
    # Author's email of the plugin
    author_email = ""
 
    # Is this plugin configurable?
    # if True, method config_widget() should be implemented.
    configurable = False
 
    # Can this plugin be disabled by the user? Use with care.
    can_be_disabled = False
 
    def __init__(self):
        pass
 
    def setup(self):
        """
        Called once, when plugin gets installed.
        """
 
    def initialize(self):
        """
        Called at application start.
        Do all necessary things here to bring up the plugin.
        """
 
    def delayed_initialize(self):
        """
        Called after full start of the application, to set up other tasks 
        that are not that important. Can be called async.
        """
 
    def config_widget(self):
        """
        This method, if implemented, must return a QWidget, which then will get 
        loadedinto the config settings page of MedUX. The widget can have
        an optional method 'validate()' that takes no arguments and is called
        immediately after the user clicks OK. Changes are applied if
        (and only if) the validate method returns True.
        """
        raise NotImplementedError()
 
    def save_settings(self):
        """
        Save settings that are configured via the config_widget.
        This could be done individually, the preferred way is using
        the MedUX settings API.
        """
        raise NotImplementedError()

Some code ideas are taken from the calibre project, all code listed here is licensed under the GPLv3.

en/dev/drafts/plugins.1508959300.txt.gz · Last modified: 2017/10/25 21:21 by nerdoc