|
From: Ian B. <ia...@co...> - 2003-05-06 23:00:51
|
I made some changes, and it should now be possible for SQLObject classes
to inherit from each other. The inheritance structure is not, however,
reflected in the database. So:
class Person(SQLObject):
name = StringCol(length=20)
class Employee(Person):
salary = CurrencyCol()
The employee table is then expected to have both a name and salary
column, and references to Person objects cannot transparently reference
Employee instances (you have to reference one or the other).
I like the idea of subclasses (like Employee) sharing a primary key with
their superclass, and potentially the superclass having references as to
which subclass they belong to (from that modeling paper Luke referenced
a while ago). But I'm not sure how best to actually implement that --
both in the database/SQL, and in the Python side. So that's a future
goal, and wouldn't replace this current kind of inheritance (just
provide an alternative).
Ian
|