Plug-in manager with python

Plugins manager is a tool to manage plugins of you application, with plugin you can easy to add or remove functionality from you application. Now i will try to describe a simple plugin manager that i build with python, plugin manager need some of standard code that you are used.

I will try to describe some standard i use to:
1. Plugins Description file
Format file : [name you will use]-zooapps-plugin
Layout :
#-plugin configurations
PLUGIN_NAME=File Object
MODULE=FileObject
VERSION=0.0.1.alpha
DEVELOPER=Syahreza Octadian
DESCRIPTION=Objects plugins to handle file processing
CREATED_DATE=13-May-2009

Description :
PLUGIN_NAME mean name of your plugins
MODULE mean python module of your plugins
VERSION, DEVELOPER, DESCRIPTION, CREATED_DATE just other information that you use to describe your plugin.

2. Plugins directory
Plugins directory is important to tell the plugins manager where to load plugin.

How to make plugins manager:
1. Append you plugins directory to python path

import sys

sys.path.append('your/plugins/directory')

2. Read your plugins description file

    def loadParameters(self):
        par = parameters.Parameter()
        cfg = par.getParams(self.params['PLUGIN_DIR'] + os.path.sep + self.params['PLUGIN_NAME'])
        return cfg

3. Load your pluguins module describe

obj = __import__(cfg['MODULE'])

see complete code.

To use this script you will need parobjects module.

Good Luck


About this entry