signals
Signals and SignalEmitter that gathers the signals on models Meta. Used to signal receivers functions about events, i.e. post_save, pre_delete etc.
Signal
Signal that notifies all receiver functions. In ormar used by models to send pre_save, post_save etc. signals.
Source code in ormar\signals\signal.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
connect(receiver)
Connects given receiver function to the signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
receiver |
Callable
|
receiver function |
required |
Raises:
Type | Description |
---|---|
SignalDefinitionError
|
if receiver is not callable or not accept **kwargs |
Source code in ormar\signals\signal.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
disconnect(receiver)
Removes the receiver function from the signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
receiver |
Callable
|
receiver function |
required |
Returns:
Type | Description |
---|---|
bool
|
flag if receiver was removed |
Source code in ormar\signals\signal.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
send(sender, **kwargs)
async
Notifies all receiver functions with given kwargs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sender |
Type[Model]
|
model that sends the signal |
required |
kwargs |
Any
|
arguments passed to receivers |
{}
|
Source code in ormar\signals\signal.py
84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
SignalEmitter
Bases: dict
Emitter that registers the signals in internal dictionary. If signal with given name does not exist it's auto added on access.
Source code in ormar\signals\signal.py
99 100 101 102 103 104 105 106 107 108 109 110 111 |
|