MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / register_object

Method register_object

lib/sqlalchemy/orm/unitofwork.py:305–337  ·  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

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