Re: [SQLObject] two beginner's questions
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Luke O. <lu...@me...> - 2003-04-28 23:19:49
|
> On Mon, 2003-04-28 at 12:21, Bud P.Bruegger wrote: > > 1. is it possible that I have to assign __connection__ before > defining > > subclasses of SQLObject? When I don't do this, I seem to run > into > > problems. > > Yes, or define _connection in each subclass. Or define a superclass for all your sublcasses that defines _connection. > > 2. is there a way to control redundancy in the following example: ... > I had this same problem; I tried to do the same thing by making > supertest a class and test1 and test2 subclasses, but that didn't > work. > It doesn't look like the architecture allows this. Is that right? Correct, the architecture is a single level of abstraction between a relational database and python objects. It is a significantly harder piece of work to map arbitrary inheritance trees to a relational database, with specific tradeoffs on either the relational or inheritance/type side of things. http://www.agiledata.org/essays/mappingObjects.html makes many points about the challenges here, and possible implementations. Alternatively, I tend to subscribe to Chris Date's views on the merits of Relation-driven (relational calculus view of types) data design as opposed to Object-driven data design. (http://www.dbdebunk.com/). As a thin-mapper, I feel that SQLObject supports this viewpoint (but that doesn't everyone on this list does :). Back on track: I would personally recommend that the solution in the Relational world is probably Frank's Lang(SQLObject), with foreignKeys in your other classes. Inheritance for the sake of Implementation is to be particularily wary of for me, and that's what this case is. - Luke |