Hi, I'd appreciate any thoughts on this; it seems like there are ways to do much more complex versions, so I guess I'm just missing a simple way to achieve it:
I have some polymorphic classes which inherit from a single parent class. The parent has the table mapped on it, and also defines a fair bit of functionality for itself.
The child classes don't have any different fields, but do need to define a lot of their own functionality. Because there are a lot of methods involved, I'm interested in making the parent class abstract so that child classes are forced to define certain functions.
To use the traditional example:
class Employee(Base):
__tablename__ = 'employee'
__metaclass__ = abc.ABCMeta
__mapper_args__ = {
'polymorphic_on':type,
}
@abc.abstractmethod
def calculate_bonus(self):
"""Each child class *must* implement this"""
class Manager(Employee):
__mapper_args__ = {
'polymorphic_identity':'manager'
}
The above will fail due to metaclass conflict, as you would expect.
I've looked at a lot of ways of doing this, but none of them seemed right.
Thanks for any help,
Benjamin
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
sqlamail.txt 1,1 All
"sqlamail.txt" 13L, 640C