| 212 | == Refactoring differences == |
| 213 | |
| 214 | [8223] refactored signals and {{{django.dispatch}}} with an eye towards speed. The net result was up to a 90% improvement in the speed of signal handling, but along the way some backwards-incompatible changes were made: |
| 215 | |
| 216 | * All handlers now must be declared as accepting {{{**kwargs}}}. |
| 217 | * Signals are now instances of {{{django.dispatch.Signal}}} instead of anonymous objects. |
| 218 | * 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. |
| 219 | * The {{{Anonymous}}} and {{{Any}}} sender options no longer exist. You can still receive signals sent by any sender by using {{{sender=None}}} |
| 220 | |
| 221 | So, a quick summary of the code changes you'd need to make: |
| 222 | |
| 223 | || '''Before''' || '''After''' || |
| 224 | || {{{def my_handler(sender)}}} || {{{def my_handler(sender, **kwargs)}}} || |
| 225 | || {{{my_signal = object()}}} || {{{my_signal = django.dispatch.Signal()}}} || |
| 226 | || {{{dispatcher.connect(my_handler, my_signal)}}} || {{{my_signal.connect(my_handler)}}} || |
| 227 | || {{{dispatcher.send(my_signal, sender)}}} || {{{my_signal.send(sender)}}} || |
| 228 | || {{{dispatcher.connect(my_handler, my_signal, sender=Any)}}} || {{{my_signal.connect(my_handler, sender=None)}}} || |
| 229 | |