MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / register_object

Method register_object

lib/sqlalchemy/orm/unitofwork.py:307–339  ·  view source on GitHub ↗
(
        self,
        state: InstanceState[Any],
        isdelete: bool = False,
        listonly: bool = False,
        cancel_delete: bool = False,
        operation: Optional[str] = None,
        prop: Optional[MapperProperty] = None,
    )

Source from the content-addressed store, hash-verified

305 self.presort_actions[key] = _Preprocess(processor, fromparent)
306
307 def register_object(
308 self,
309 state: InstanceState[Any],
310 isdelete: bool = False,
311 listonly: bool = False,
312 cancel_delete: bool = False,
313 operation: Optional[str] = None,
314 prop: Optional[MapperProperty] = None,
315 ) -> bool:
316 if not self.session._contains_state(state):
317 # this condition is normal when objects are registered
318 # as part of a relationship cascade operation. it should
319 # not occur for the top-level register from Session.flush().
320 if not state.deleted and operation is not None:
321 util.warn(
322 "Object of type %s not in session, %s operation "
323 "along '%s' will not proceed"
324 % (orm_util.state_class_str(state), operation, prop)
325 )
326 return False
327
328 if state not in self.states:
329 mapper = state.manager.mapper
330
331 if mapper not in self.mappers:
332 self._per_mapper_flush_actions(mapper)
333
334 self.mappers[mapper].add(state)
335 self.states[state] = (isdelete, listonly)
336 else:
337 if not listonly and (isdelete or cancel_delete):
338 self.states[state] = (isdelete, False)
339 return True
340
341 def register_post_update(self, state, post_update_cols):
342 mapper = state.manager.mapper.base_mapper

Callers 9

_flushMethod · 0.95
_get_test_uowMethod · 0.95
_get_test_uowMethod · 0.95
presort_deletesMethod · 0.80
presort_savesMethod · 0.80
presort_deletesMethod · 0.80
presort_savesMethod · 0.80
_process_key_switchesMethod · 0.80
presort_savesMethod · 0.80

Calls 4

_contains_stateMethod · 0.80
warnMethod · 0.45
addMethod · 0.45

Tested by 2

_get_test_uowMethod · 0.76
_get_test_uowMethod · 0.76