Cast into custom type
Diez B. Roggisch
deets at nospam.web.de
Tue Nov 3 11:00:23 CET 2009
Henning Bredel schrieb:
> I created a plugin mechanism for my application orientating
> at the mechanism described by Martin Alchy in
> 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.
More information about the Python-list