(state, newvalue, oldvalue, initiator, **kw)
| 104 | item_state._orphaned_outside_of_session = True |
| 105 | |
| 106 | def set_(state, newvalue, oldvalue, initiator, **kw): |
| 107 | # process "save_update" cascade rules for when an instance |
| 108 | # is attached to another instance |
| 109 | if oldvalue is newvalue: |
| 110 | return newvalue |
| 111 | |
| 112 | sess = state.session |
| 113 | if sess: |
| 114 | if sess._warn_on_events: |
| 115 | sess._flush_warning("related attribute set") |
| 116 | |
| 117 | prop = state.manager.mapper._props[key] |
| 118 | if newvalue is not None: |
| 119 | newvalue_state = attributes.instance_state(newvalue) |
| 120 | if ( |
| 121 | prop._cascade.save_update |
| 122 | and (key == initiator.key) |
| 123 | and not sess._contains_state(newvalue_state) |
| 124 | ): |
| 125 | sess._save_or_update_state(newvalue_state) |
| 126 | |
| 127 | if ( |
| 128 | oldvalue is not None |
| 129 | and oldvalue is not attributes.NEVER_SET |
| 130 | and oldvalue is not attributes.PASSIVE_NO_RESULT |
| 131 | and prop._cascade.delete_orphan |
| 132 | ): |
| 133 | # possible to reach here with attributes.NEVER_SET ? |
| 134 | oldvalue_state = attributes.instance_state(oldvalue) |
| 135 | |
| 136 | if oldvalue_state in sess._new and prop.mapper._is_orphan( |
| 137 | oldvalue_state |
| 138 | ): |
| 139 | sess.expunge(oldvalue) |
| 140 | return newvalue |
| 141 | |
| 142 | event.listen( |
| 143 | descriptor, "append_wo_mutation", append, raw=True, include_key=True |
nothing calls this directly
no test coverage detected