"Plugin" architecture - how to do?
nate.finch at gmail.com
Fri Apr 6 15:59:23 CEST 2007
On Apr 5, 10:57 am, anglozax... at gmail.com wrote:
> I'm making a program that consists of a main engine + plugins. Both
> are in Python. My question is, how do I go about importing arbitrary
> code and have it be able to use the engine's functions, classes, etc?
For a true plugin architecture, you don't have the main engine calling
methods on the plugin. What you do is have an API on your engine with
methods the plugin can call and events it can hook into. The events
are how the engine communicates state to any plugins, without having
to know who they are or what they do. Your engine has a configuration
that tells it what plugins to load (which the plugins presumably
modified when they installed themselves) or otherwise has some
standard way that the engine can figure out what plugins need to be
Now granted, I don't specifically know how to do this via python..
but, maybe what I've said will send you in the right direction.
More information about the Python-list