On Mar 19, 2009, at 9:44 AM, Martin wrote:
> > I've written my own deep_clone for SA Object Trees, which is > exploiting quite some lowlevel calls inside SA > > This has brought me to reimplement the cloning for every major version > change, I started in 0.3, updated to 0.4 with some major rework, but I > simply cant get it to work with 0.5.2, and I wonder how or why?!?!?! > > there is 2 major reasons I could identify > > 1) is_backref allowed to judge which side of a backref I was on, now > no similar property exists, which also means I run into circular > CLONEs, which to prevent, there only seems to be > (v.property.backref and v.property.backref.kwargs == {}) to judge what > side I'm on to prevent cycles during deep traversal, use a recursion set: def visit_element(element, set): if element in set: return else: set.add(element) for c in element.sub_elements: visit_element(c, set) Look at the source code to cascade_iterator() in mapper.py and property.py, as well as session.merge(), to see some deep traversal examples. > 2) when I have a InstrumentedList property, i.e. I would getattr > (newobj, 'property').append(elem), this would automatically set > elem.`backref ` to the correct value, whereas now this is not updated > until flushed, which causes me tremendous consternation only an unloaded collection should have that behavior, for obvious reasons (i.e. backrefs shouldn't be loading collections without knowing that youll ever look at them). a scalar many-to-one should get populated. when the reverse collection is lazy-loaded, the extra elements you've added should get thrown onto the end of the list - this occurs wihtin get_committed_value() in attributes.py. the behavior is meant to be transparent for a user application so your copy routine shouldn't have any difference. --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---