Cast into custom type
Diez B. Roggisch
deets at nospam.web.de
Tue Nov 3 05:00:23 EST 2009
Henning Bredel schrieb:
> Hi,
>
> I created a plugin mechanism for my application orientating
> at the mechanism described by Martin Alchy in
>
> http://martyalchin.com/2008/jan/10/simple-plugin-framework/
>
> Now I'd like to call methods like `initialize(parent)' when
> the user chooses to use a plugin. As described in the blog
> mentioned above, I only have access to the general type called
> `PluginMount' (holding all the actual plugin instances).
>
> I tried to define "abstract" methods in PluginMount type
> raising a `NotImplementedError' but it seems, there is no
> late binding (similar to Java), so the right method would be
> called. Only the message
>
> TypeError: unbound method initialize() must be called
> with GeoCache instance as first argument (got PluginMount
> instance instead)
>
> `GeoCache' would be the plugin type. What is strange, is the
> fact, that when asking what instances are hold by PluginMount
>
> [<class 'geocacheplugin.GeoCache'>]
>
> is listed. So it seems, that no late binding is applied when
> calling the `initialize(self, parent)' method.
>
> I'm quite new using Python, so this might be a quite basic
> question caused by some misunderstandings in general. Feel
> free to point me to appropriate site to solve my problem.
It seems that GeoCache is not a subclass of PluginMount.
Diez
More information about the Python-list
mailing list