4.3. Plugins

The current plugin infrastructure is somewhat less powerful than what we desire but that should be addressed in the future. Right now, a plugin, simply consists in the possibility to add some functionality that is executed by browsing a plugin list. So no chance to modify/add menu entries, buttons in the toolbar or hooks triggered under given events. Plugins must be written in Python, a wrapper should be easily developed using QtScript to create JavaScript plugins.

Plugins need to be created/copied in a subdirectory inside bin/plugins/ directory. Each directory can contain several plugins, but each directory needs one __terp__.py file with the following structure:


{
	'plugin_name' : {
		'model' : 'model where the plugin should be available',
		'string' : 'Plugin Title',
		'action' : 'plugin_directory.function_name'
	}
}
  

Here follows an example of the workflow_print plugin:


{
	'workflow_print_simple': {
		'model':'.*',
		'string':'Print Workflow',
		'action': 'workflow_print.wkf_print_simple'
	},
	'workflow_print': {
		'model':'.*',
		'string':'Print Workflow (Complex)',
		'action': 'workflow_print.wkf_print'
	}
}
  

In this example, the wkf_print_simple and wkf_print functions are defined inside the workflow_print/__init__.py file as:


import service
import common

def wkf_print(datas):
	datas['nested']=True
	obj = service.LocalService('action.main')
	obj.exec_report('workflow.instance.graph', datas)
	return True

def wkf_print_simple(datas):
	datas['nested']=False
	obj = service.LocalService('action.main')
	obj.exec_report('workflow.instance.graph', datas)
	return True
  

Obviously all client modules are available. Here, the plugin uses the service facilities to show a report.