Problem with method overriding from base class
- From: <Dominique.Holzwarth@xxxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 10:05:39 +0100
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 ;-))
.
- Follow-Ups:
- Re: Problem with method overriding from base class
- From: bruno.desthuilliers@xxxxxxxxx
- Re: Problem with method overriding from base class
- From: Duncan Booth
- Re: Problem with method overriding from base class
- Prev by Date: [ANN] Vellum 0.4 (it builds things, mostly books)
- Next by Date: Re: Finding Full Path to Process EXE
- Previous by thread: [ANN] Vellum 0.4 (it builds things, mostly books)
- Next by thread: Re: Problem with method overriding from base class
- Index(es):
Relevant Pages
|
|