Hey Michael,

Great, rev 1555 worked for me! If it would help, please convert this lot
into a unit test/s. I'll keep on going and will let you know if any more
issues arise.

Thanks!

Nick

Michael Bayer wrote:
> hey Nick -
>
> these are terrific tests, sorry i didnt have this all working ahead of
> time but this is how this stuff has ended up getting done in a lot of
> cases...
>
> made a few tweaks to polymorphic loading in changeset 1555.   a few
> changes to your script, which is attached.  the "default='0'" on all
> your ID columns was confusing it in many cases, so i took those out
> (if you really need those there, we can look into making them less
> confusing to the mapper).  secondly, since you are making a
> relationship directly to the MagazinePage mapper which you want to be
> polymorphic towards the ClassifiedPage mapper, that mapper needs its
> own polymorphic selectable (and i am blown away that this works at
> all...i hadnt taken it this far):
>
> page_join = polymorphic_union(
>     {
>         'm': page_table.join(magazine_page_table),
>         'c':
> page_table.join(magazine_page_table).join(classified_page_table),
>         'p': page_table.select(page_table.c.type=='p'),
>     }, None, 'page_join')
>
> magazine_join = polymorphic_union(
>     {
>         'm': page_table.join(magazine_page_table),
>         'c':
> page_table.join(magazine_page_table).join(classified_page_table),
>     }, None, 'page_join')
>
> page_mapper = mapper(Page, page_table, select_table=page_join,
> polymorphic_on=page_join.c.type, polymorphic_identity='p')
>
> magazine_page_mapper = mapper(MagazinePage, magazine_page_table,
> select_table=magazine_join, inherits=page_mapper,
> polymorphic_identity='m', properties={
>     'magazine': relation(Magazine, backref=backref('pages'))
> })
>
> classified_page_mapper = mapper(ClassifiedPage, classified_page_table,
> inherits=magazine_page_mapper, polymorphic_identity='c')
>
> so the attached file does that and also retrieves two ClassifiedPage
> and one MagazinePage off the relationship.
>
> Would there be any issue if I converted these scripts into further
> unit tests to be included with the SA distribution ?  youve come
> across some patterns that have not been done before and these are very
> useful.
>
[[ snip ]]


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to