| 1097 | |
| 1098 | == Signal refactoring == |
| 1099 | |
| 1100 | [8223] refactored signals and {{{django.dispatch}}} with an eye towards speed. The net result was up to a 90% reduction in the speed of signal handling, but along the way some backwards-incompatible changes were made: |
| 1101 | |
| 1102 | * All signals now must be declared as accepting {{{**kwargs}}}. |
| 1103 | * Signals are now instances of {{{django.dispatch.Signal}}} instead of anonymous objects. |
| 1104 | * Connecting, disconnecting, and sending signals are done via methods on the {{{Signal}}} object instead of through module methods in {{{django.dispatch.dispatcher}}}. The module-level methods are deprecated. |
| 1105 | * The {{{Anonymous}}} and {{{Any}}} sender options no longer exist. You can still receive signals sent by any sender by |
| 1106 | |
| 1107 | So, a quick summary of the code changes you'd need to make: |
| 1108 | |
| 1109 | || '''Before''' || '''After''' || |
| 1110 | || {{{def my_handler(sender)}}} || {{{def my_handler(sender, **kwargs)}}} || |
| 1111 | || {{{my_signal = object()}}} || {{{my_signal = django.dispatch.Signal()}}} || |
| 1112 | || {{dispatcher.connect(my_handler, my_signal)}} || {{{my_signal.connect(my_handler)}}} || |
| 1113 | || {{{dispatcher.send(my_signal)}}} || {{{my_signal.send()}}} || |
| 1114 | || {{{dispatcher.connect(my_handler, my_signal, sender=Any)}}} || {{{my_signal.connect(my_handler, sender=None)}}} || |