[SQLObject] Using SQLObjects as Abstract Classes
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Brad B. <br...@bb...> - 2003-07-24 19:41:27
|
Hi all, How can I use an SQLObject-derived class as an abstract base class? E.g. class Foo(SQLObject): bar = IntCol() def abstractMethod(self): raise NotImplementedError("Override me.") class Bar(Foo): def abstractMethod(self): print self.bar If I now do: b = Bar.new(bar = 1) b.abstractMethod() this will break, with an error message (traceback not shown): psycopg.ProgrammingError: ERROR: Relation "bar" does not exist If I add _table = 'foo' to Foo, the same error results. If I add _table = 'foo' to Bar instead, it Does The Right Thing, however this is ugly. Bar will never actually create a table, I just want to be able to define the common functionality and (of course) the data mapping in the base class Foo, and then override and extend in Bar, whilst having my properties magically save themselves into the database. How do I lay this out then? Regards, -- Brad Bollenbach BBnet.ca |