Plugins accessing parent state

hajducko at hajducko at
Fri Mar 28 09:16:42 CET 2008

Does anyone have some design ideas ( or can point me at the right
design pattern, because I can't find it. ) for having a plugin being
able to access a parent's state?

For example, let's say I have a class that receives some commands.
When it gets a command, it checks which of the registered plugins
deals with that command and passes the details of the command off to
that plugin.  So I'd end up with something like..

result =

Now, I want to write a plugin called "help" that loops through all the
registered plugins and prints out their doc strings.  If all my plugin
is getting is the msg details, how is it supposed to get the list of
available plugins from the calling class?

Or, for instance, let's say my class loads a configuration file that
lists a set of admins who can enter commands.  I want the plugins, if
they so choose,  to be able to test if the msg came from an admin, but
again, I'm not passing the admin list into every plugin, it's just in
my calling class.  I could make the plugin specify an attribute for
itself, like "admin_only" and test for that before I pass the command
but what if certain parts of the plugin are to be restricted and
others aren't, based on the details of the command sent?

Is this as simple as just passing the instance of my class to each
plugin?  It doesn't seem like the proper thing to do, because now the
plugin class has the capability of accessing the whole bot's

I realize that this is all just theory but I'd appreciate any points
in the right direction.



More information about the Python-list mailing list