Michael Bayer wrote: > Ok, theres a lot going on with this one.... > > the biggest problem youre hitting is that Element.mapper is made > against the table "element_table", so when adding a property to > Element.mapper, the primaryjoin has to somehow get back to that > table. Element's mapper doesnt know anything about the > "element_type_join" selectable so it cannot create synchronization > rules for that relation. Similarly, if you try putting a backref > directly into the SpecLine mapper's 'master' property, which is in > theory how it should be done, that fails also since you are dealing > with the non-primary mapper for the Element table....this has to be > that way since only one Mapper is responsible for the actual saving of > an object, that is the primary mapper. > > So to work around that, you can set up a two-way "specification" > property on the Element class by adding another property to SpecLine, > which I called "_element", and it just deals with the Element class > directly. While this allows the example to save to the DB (with some > other adjustments i will describe), Im not sure if this workaround is > going to really hold up. the general problem is that the polymorph > thing I came up with, which is not really a fully built-in feature as > of yet (but obviously should be), doesnt have great support for backrefs. > > the next problem is, "add_property" and also "backref" which relies > upon add_property, doesnt work so well with an inheritance > chain...because when you say m = mapper(bar, table, inherits=foo), it > copies all the properties from 'foo' to 'bar'. when you do > add_property to 'foo', that doesnt do anything for 'bar'. i will > check this in as a trac ticket. so to work around that I set up the > SpecLine mapper with the _element property much earlier, and add the > "polymorphic" properties later on via add_property. > > *then*, in your example you are appending a Detail object to the > "specification" list....I assume you never got it going that far, but > "specification" is a list of SpecLine objects, so I switched that. > > anyway, you do all that and you have whats attached. It commits, but > since you are touching upon at least two patterns that arent > supported/fully working, not sure how far it will fly as of yet. > Thanks for the clarification. I'll try plan B -- one fat table with 'type' column.
------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

