ModelSignals with abstract senders

44 views
Skip to first unread message

Alexander Hill

unread,
Jun 1, 2016, 12:36:58 AM6/1/16
to django-d...@googlegroups.com
Hi all, currently when a model signal receiver is registered with an abstract model as the sender, we allow it even though the receiver will never be called. It would be nice if the signal registry wasn't polluted by bogus entries that will never be used.

A few options:

a) Make passing an abstract model to a ModelSignal a no-op, and document that behaviour. (And possibly: add a return value to ModelSignal.connect() like we have for disconnect(), and return False when an abstract model is passed as a sender)

b) Raise a warning, and make it the user's responsibility to check if a model is abstract before registering it as a sender.

c) Allow it, and make ModelSignal respect inheritance, so that you can specify a superclass as a sender and the receiver will be called for all its subclasses, perhaps controlled by an argument to connect().

Perfectly reasonable code like that in django-model-utils [1] does this, so I don't think it warrants a warning. My inclination is to go with (a).

Cheers,
Alex

Reply all
Reply to author
Forward
0 new messages