Michael Bayer wrote:
> your extension needs to translate the row being passed to the 
> descendant mapper, i.e. inside of populate_instance.  any 
> dictionary which has Column instances for keys will work.  such as:
> 
>     def populate_instance(self, mapper, selectcontext,
>                           row, instance, identitykey, isnew):
>         newmapper = class_mapper(type(instance))
>         newrow = dict((k,row[k]) for k in list(employees.c))
>         newrow[managers.c.manager_id] = row[employees.c.person_id]
>         newrow[engineers.c.engineer_id] = row[employees.c.person_id]
>         newmapper.populate_instance(selectcontext, instance, newrow,
>                                  identitykey, isnew)
>         return True
> 

That works perfectly - thanks again! I did just notice a tiny mistake in
the docs for MapperExtension - In the populate_instance example it
passes a frommapper argument to the other mapper, but this parameter
doesn't exist.

Thanks again for all your help,

Simon

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to