Receive an object instance after a DELETE statement has been emitted corresponding to that instance. .. note:: this event **only** applies to the :ref:`session flush operation <session_flushing>` and does **not** apply to the ORM DML operations described at
(
self, mapper: Mapper[_O], connection: Connection, target: _O
)
| 1463 | """ |
| 1464 | |
| 1465 | def after_delete( |
| 1466 | self, mapper: Mapper[_O], connection: Connection, target: _O |
| 1467 | ) -> None: |
| 1468 | """Receive an object instance after a DELETE statement |
| 1469 | has been emitted corresponding to that instance. |
| 1470 | |
| 1471 | .. note:: this event **only** applies to the |
| 1472 | :ref:`session flush operation <session_flushing>` |
| 1473 | and does **not** apply to the ORM DML operations described at |
| 1474 | :ref:`orm_expression_update_delete`. To intercept ORM |
| 1475 | DML events, use :meth:`_orm.SessionEvents.do_orm_execute`. |
| 1476 | |
| 1477 | This event is used to emit additional SQL statements on |
| 1478 | the given connection as well as to perform application |
| 1479 | specific bookkeeping related to a deletion event. |
| 1480 | |
| 1481 | The event is often called for a batch of objects of the |
| 1482 | same class after their DELETE statements have been emitted at |
| 1483 | once in a previous step. |
| 1484 | |
| 1485 | .. warning:: |
| 1486 | |
| 1487 | Mapper-level flush events only allow **very limited operations**, |
| 1488 | on attributes local to the row being operated upon only, |
| 1489 | as well as allowing any SQL to be emitted on the given |
| 1490 | :class:`_engine.Connection`. **Please read fully** the notes |
| 1491 | at :ref:`session_persistence_mapper` for guidelines on using |
| 1492 | these methods; generally, the :meth:`.SessionEvents.before_flush` |
| 1493 | method should be preferred for general on-flush changes. |
| 1494 | |
| 1495 | :param mapper: the :class:`_orm.Mapper` which is the target |
| 1496 | of this event. |
| 1497 | :param connection: the :class:`_engine.Connection` being used to |
| 1498 | emit DELETE statements for this instance. This |
| 1499 | provides a handle into the current transaction on the |
| 1500 | target database specific to this instance. |
| 1501 | :param target: the mapped instance being deleted. If |
| 1502 | the event is configured with ``raw=True``, this will |
| 1503 | instead be the :class:`.InstanceState` state-management |
| 1504 | object associated with the instance. |
| 1505 | :return: No return value is supported by this event. |
| 1506 | |
| 1507 | .. seealso:: |
| 1508 | |
| 1509 | :ref:`session_persistence_events` |
| 1510 | |
| 1511 | """ |
| 1512 | |
| 1513 | |
| 1514 | class _MapperEventsHold(_EventsHold[_ET]): |