Re: Is there any way to disable dispatching of signals?

2018-07-19 Thread Melvyn Sopacua
On donderdag 19 juli 2018 18:22:46 CEST lorin...@gmail.com wrote:
> Is there any way to disable dispatching of signals?
> If not, I truly truly think there should be a way to do it :)
> 
> Possible use cases:
> - Prevent signals being called recursively because the signal code
> dispatched the same signal.

Subscribe to the signal with dispatch_uid[1].

> - Disable for scripts or management commands
> - Just bypass the signals on specific actions.

As Jason implies: both tasks of the observer, not the dispatcher. If a 
dispatcher does not 
call all registered observers as part of the API contract, you have no way to 
debug it (given 
that a signal dispatcher should be a black box to you) or at best you'd have 2 
places where 
things can go wrong instead of just one.

You thought up some use cases, but given the tone of your mail you mybe spent 
some 
time trying to shoehorn some code into a signal/observer pattern? Perhaps it's 
not the 
right fit for your problem.
-- 
Melvyn Sopacua


[1] 
https://docs.djangoproject.com/en/2.0/topics/signals/#preventing-duplicate-signals

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6325556.ifQiiisRDa%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: Is there any way to disable dispatching of signals?

2018-07-19 Thread Jason
deciding whether to act or not is really part of the signal handler, to be 
honest.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/966d4c2a-5738-4b38-b7d4-5990852a0a00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is there any way to disable dispatching of signals?

2018-07-19 Thread lorinkoz
Is there any way to disable dispatching of signals?
If not, I truly truly think there should be a way to do it :)

Possible use cases:
- Prevent signals being called recursively because the signal code 
dispatched the same signal.
- Disable for scripts or management commands
- Just bypass the signals on specific actions.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3fd1f97e-177c-4241-b7bf-9ac74abb82a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.