"Plugin" architecture - how to do?

anglozaxxon anglozaxxon at gmail.com
Mon Apr 9 15:07:00 CEST 2007


On Apr 6, 9:59 am, "Nate Finch" <nate.fi... at gmail.com> wrote:
> 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 truepluginarchitecture, you don't have the main engine calling
> methods on theplugin.  What you do is have an API on your engine with
> methods theplugincan 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
> loaded.
>
> 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.
>
> -Nate

Alright that's a good suggestion.  But the problem I'm having is that
I don't know how to execute the plugin.  I think I know how to do the
architecture, just that there needs to be some crazy circular
importing going on and I was wondering if there was a smarter way to
attack the problem.

Thanks,
Nick




More information about the Python-list mailing list