King Simon-NFHD78 wrote:
>
> class EmployeeMapperExtension(sa.MapperExtension):
>     def create_instance(self, mapper, selectcontext, row, class_):
>         cls = get_employee_class(row[employee_table.c.kind])
>         if class_ != cls:
>             return sa.class_mapper(cls)._instance(selectcontext, row)
>         return sa.EXT_PASS
> ....
>
> The only thing I'm not sure about is the mapper extension - is it OK to
> call the mapper._instance method, or is there a better way to do this?

if you call _instance like that, youre already well inside the
_instance method of the calling mapper...so its not a great way to do
it since a lot of redundant stuff will happen which may have negative
side effects.

id rather just add another plugin point on MapperExtension for this,
which takes place before the "polymorphic" decision stage at the top of
the _instance method, like get_polymorphic_identity().  that way you
could do all of this stuff cleanly in an extension (and id do that
instead of making polymorphic_identity into a list).  hows that sound?


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to