Hello,

I am pretty determined to find a way to get (a simplified version of)
multiple inheritance working with SA. The simplification lies in that
no overriding of attributes will be possible (but I don't know whether
that is significant). I was thinking of a schema as follows:

--------------------------------------------------------------------------------------

metadata = MetaData()

base1_table = Table("base1_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('str', String)
    )

base2_table = Table("base2_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('int', Integer)
    )

claz1_table = Table("claz1_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('base1_id', None, ForeignKey('base1_table.id')),
    Column('base2_id', None, ForeignKey('base2_table.id')),
    Column('assoc_id', None, ForeignKey('assoc_table.id'))
    )

assoc_table = Table("assoc_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('name', String(50), nullable=False),
    Column('type', String(50), nullable=False)
)

base3_table = Table("base3_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('assoc_id', None, ForeignKey('assoc_table.id')),
    Column('bool', Boolean)
    )

claz2_table = Table("claz2_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('base3_id', None, ForeignKey('base3_table.id')),
    Column('date', Date)
    )

class base1(object):
    pass
class base2(object):
    pass
class base3(object):
    pass
class claz1(base1, base2):
    pass
class claz2(base3):
    pass

# do mappings, relationships and e.g. be able to

c1 = claz1(str = "hello", int = 17)
setattr(c1, name, claz2(bool = True, date = Date(2010,9,10)))

-----------------------------------------------------------------------------------------------------------------

I am still pretty new to SA. Can anyone give me any hints, tips,
issues with this scheme (e.g. about how to do the mappings,
descriptors, etc)?

The step after will be to write factory functions/metaclasses to
generate these dynamically.

Multiple inheritance is very important for my use case.

Cheers, Lars

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to