On Aug 17, 2008, at 10:18 PM, Russell Warren wrote:
> > After struggling with this a lot longer I've realized that my > subclassing problem is fundamentally simpler than I've described. > > My application generates the database from scratch. I use declarative > to avoid having to define the database table fields, redefine them in > my objects, and then map them. I have a lot of tables in my > application and it saves a lot of copy-pasting. > > Two other things: > > 1. I like having the entire database definition in one file > - ie: all table defs in one place > - with declarative this means having the objects there, too > > 2. I want to define unmapped functionality in additional files > - eg: a "User" object's table in the dbdef file, but actual user > functions > (eg: User.SendEmail) defined in another file (eg: User.py) where > the full > support code exists for user management > - I don't want the dbdef file cluttered with code not related to > table defs if you want your mapping defintions decoupled from your class definitions, here are your options: 1. use mapper(). This is why SQLA was built this way. There is no need for "re" defintion of columns or copy-pasting as the mapper pulls them from the Table automatically - its completely DRY (but more spread out). 2. use mixins. I.e. your "unmapped functionality" is provided by a mixin which you define as a second base class for a mapped class along with declarative base. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---