On Feb 28, 2006, at 11:25 AM, Marko Mikulicic wrote:


On 28.02.2006., at 16:09, Michael Bayer wrote:


it seems to me it would be "easier" to just map against the actual SELECT statement that joins all three tables, and not use mapper inheritance for this. youd have one Mapper that knows about the Base class. then your MapperExtension would override create_instance to provide Organization or Person objects....thats the single point at which objects are instantiated. that way the mapper would just deal with Base objects and not even know about the subclasses.

This was the first idea that I tried, but didn't know how to fill new instances from the row, without playing with internals that may change between svn releases. Is there an example using create_instance?


how many classes do you want to be able to add to this ? doing a giant SELECT that outerjoins many tables, with only one being used for each row, will perform very poorly.

anyway, create_instance is not too different from the append_result you already figured out:

class MyExt(MapperExtension):
        def create_instance(self, mapper, row, imap, class_):
                if row['col1'] == 'foo':
                        return Organization(_mapper_nohistory=True)
                else:
                        return Person(_mapper_nohistory=True)





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to