Problem with method overriding from base class



Hello everyone

I have defined some sort of 'interface class' and a factory function that creates instance objects of specific classes, which implement that interface:

Interface definition:
***************************************************************************************
import GUI.webGUI as webGUI

class EditInterface(webGUI.WebGUI):
def addEntry(self, *p):
raise 'EditInterface.addEntry(): Interface must not be called directly'
def clearScreen(self, *p):
raise 'EditInterface.clearScreen(): Interface must not be called directly'
def deleteEntry(self, *p):
raise 'EditInterface.deleteEntry(): Interface must not be called directly'
def editEntry(self, *p):
raise 'EditInterface.editEntry(): Interface must not be called directly'
def processUserInput(self, *p):
raise 'EditInterface.processUserInput(): Interface must not be called directly'
def show(self, entry, statustext):
raise 'EditInterface.show(): Interface must not be called directly'
***************************************************************************************

Factory:
***************************************************************************************
def factory(type, *p):
if type == common.databaseEntryTypes[0]:
return module1.Class1(*p);
elif type == common.databaseEntryTypes[1]:
return module2.Class2(*p);
elif type == common.databaseEntryTypes[2]:
return module3.Class3(*p);
elif type == common.databaseEntryTypes[3]:
return module4.Class4(*p);
***************************************************************************************

Implementing Class1:
***************************************************************************************
import editInterface

class Class1(editInterface.EditInterface):

def __init__(self, product, database):
# do something here ...

def showEntry(self, entry, statustext):
# do something here as well, return some string...
***************************************************************************************

Now, when I want to create an Instance of Class1 I do:

myClass1Instance = factory.factory(common.databaseEntryTypes[1], 'Name', databaseObj )

Which seems to work fine according to the debugger. But when I do next:

msg = myClass1Instance.show(firstEntry, '')

Then the show() method of the class 'EditInterface' is called instead of the show() method of the class 'Class1' !!
Does anyone have an idea why the method of the base class is called instead of the method of the derived class and how can I do it, so that the show() of Class1 is called instead?

Greetings
Dominique

(did some data hiding there, but shouldn't really matter for the problem ;-))

.



Relevant Pages

  • Re: Need some advice
    ... parts are independent from the others, except for a few interface items ... def reduction: ... > the numerical equivalent of each letter in a name and I was going to ...
    (comp.lang.python)
  • Re: A little stricter type checking
    ... def f: ... but that the interface is there at least, while in the former both steps ... Of course it is not a full replacement of a type declaration, ...
    (comp.lang.python)
  • Re: IronPython and COM Interface
    ... I'm new to IronPython and COM so please bear with me. ... I have a COM interface provided to me. ... def OnLevel2Data: ... # Wrap the callback class to turn it into an IDispatch object ...
    (comp.lang.python)
  • Re: Controlling acces to object instantiation?
    ... interface SomeFeature ... public class FeatureFactory ... Class::new do class << self def foo; 42; end end def bar; 42.0; end end), ...
    (comp.lang.ruby)
  • Re: Strategy Design Pattern
    ... really apply to Python per say, but the idea behind the patterns can be ... think the goal is to abstract out of the class an algorithm that can ... this is quite simple - decide upon an interface that the ... def TakeOff: ...
    (comp.lang.python)