Mark an attribute on an instance as 'modified'. This sets the 'modified' flag on the instance and establishes an unconditional change event for the given attribute. The attribute must have a value present, else an :class:`.InvalidRequestError` is raised. To mark an object "dirt
(instance: object, key: str)
| 2799 | |
| 2800 | |
| 2801 | def flag_modified(instance: object, key: str) -> None: |
| 2802 | """Mark an attribute on an instance as 'modified'. |
| 2803 | |
| 2804 | This sets the 'modified' flag on the instance and |
| 2805 | establishes an unconditional change event for the given attribute. |
| 2806 | The attribute must have a value present, else an |
| 2807 | :class:`.InvalidRequestError` is raised. |
| 2808 | |
| 2809 | To mark an object "dirty" without referring to any specific attribute |
| 2810 | so that it is considered within a flush, use the |
| 2811 | :func:`.attributes.flag_dirty` call. |
| 2812 | |
| 2813 | .. seealso:: |
| 2814 | |
| 2815 | :func:`.attributes.flag_dirty` |
| 2816 | |
| 2817 | """ |
| 2818 | state, dict_ = instance_state(instance), instance_dict(instance) |
| 2819 | impl = state.manager[key].impl |
| 2820 | impl.dispatch.modified(state, impl._modified_token) |
| 2821 | state._modified_event(dict_, impl, NO_VALUE, is_userland=True) |
| 2822 | |
| 2823 | |
| 2824 | def flag_dirty(instance: object) -> None: |
no test coverage detected