Re: Automatically loading and initialising objects from a plugins directory

2008-07-29 Thread kpd
On Jul 25, 7:50 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > It's a potentially brain-exploding topic, -that you made very understandable. Thanks for posting that explanation and example. -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatically loading and initialising objects from a plugins directory

2008-07-25 Thread Fredrik Lundh
Dave Challis wrote: I'll have a look into metaclasses too, haven't stumbled upon those yet at all. It's a potentially brain-exploding topic, though, so if the above solution works for you, you might want to leave it at that ;-) But very briefly, a metaclass is a something that's responsible

Re: Automatically loading and initialising objects from a plugins directory

2008-07-25 Thread Dave Challis
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Fredrik Lundh wrote: > so now you're no longer supporting mixins and multiple-level > inheritance? why not just tweak Diez' example a little: > > for name in dir(plugin): > > thing = getattr(plugin, name) > > # make sure this is a plugin >

Re: Automatically loading and initialising objects from a plugins directory

2008-07-22 Thread Fredrik Lundh
Dave Challis wrote: Thanks for that, it helped as a starting point. I had some trouble with using issubclass though (issubclass(Plugin, Plugin) returns true), which was complicating things. I modified your code to the following instead (which may well have it's own pitfalls I'm not aware of!):

Re: Automatically loading and initialising objects from a plugins directory

2008-07-22 Thread Dave Challis
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Diez B. Roggisch wrote: > Dave Challis wrote: > >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> I'm trying to write some code which: >> 1. Finds all modules in a plugin directory >> 2. Imports those modules >> 3. Creates an instance of each

Re: Automatically loading and initialising objects from a plugins directory

2008-07-22 Thread Diez B. Roggisch
Dave Challis wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I'm trying to write some code which: > 1. Finds all modules in a plugin directory > 2. Imports those modules > 3. Creates an instance of each object defined in the module (each module > will contain exactly 1 object, which