I wanted to do something like this in the past, and in the end, rather than using polymorphic mappers it made more sense to create a MapperExtension which overrides create_instance. In create_instance you can examine your 'typ' column to decide what class to create, selecting one of your Manager/Demigod classes if necessary, or falling back to the Person class otherwise. Hope that helps, Simon
________________________________ From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rick Morrison Sent: 06 March 2007 01:12 To: sqlalchemy Subject: [sqlalchemy] Polymorphic collections / ticket #500 The fix for ticket #500 breaks a pattern I've been using. It's most likely an anti-pattern, but I don't see a way to get what I want in SA otherwise. I've got a series of "entities" class Person(): pass class Manager(Person): def __init__(self): # do manager stuff class Demigod(Person): def __init__(self): # do demigod stuff etc. there are mappers for each of these entities that inherit from Person(), so all of the normal Person() properties exist, but Person() itself is not polymorphic. That's on purpose, and because the class hierarchy of Manager(), etc, is not exhaustive, and I occasionally want to save instances of Person() directly. If I make the Person() class polymorphic on a column of say "typ", then SA clears whatever "typ" I may have tried to set directly, and seems to make me specify an exhaustive list of sub-types. And so I leave Person() as non-polymorphic. I also have a collection of Person() objects on a different mapper, which can load entity objects of any type. Before rev #2382, I could put a Manager() in a Person() collection, and it would flush OK. Now it bitches that it wants a real polymorphic mapper. I don't want to use a polymorphic mapper, because I don't want to specify an exhaustive list of every class that I'm ever going to use. What to do? Thanks, Rick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---