On Feb 13, 2010, at 10:02 AM, Jannis Leidel wrote:
> Maby we should also switch notification.models.send from being a custom
> implementation to a signal itself, e.g.:
>
> # notification/signals.py
> notification = django.dispatch.Signal(providing_args=["user",
> "extra_context", "on_site", "queue", "now"])
>
> # notification/models.py
> from notification import signals
>
> def send_handler(sender, *args, **kwargs):
> queue_flag = kwargs.pop("queue", False)
> now_flag = kwargs.pop("now", False)
> assert not (queue_flag and now_flag), "'queue' and 'now' cannot both be
> True."
> if queue_flag:
> return queue(*args, **kwargs)
> elif now_flag:
> return send_now(*args, **kwargs)
> else:
> if QUEUE_ALL:
> return queue(*args, **kwargs)
> else:
> return send_now(*args, **kwargs)
>
> signals.notification.connect(send_handler)
>
> def send(*args, **kwargs):
> """
> Backwards compatible, lalalala
> """
> users, label = args
> kwargs["users"] = users
> signals.notification.send(sender=label, **kwargs)
I am not a big fan of this at all. IMO this is signal abuse. Signals make sense
when the sender doesn't control the receiver. This implementation means the
receiver (or at least the default receiver) is known within the same Python
package. Satchmo does this sort of thing all over to offer extensibility and it
leaves a really bad taste in my mouth. I am not sure what the benefit is other
than allowing user code to override the full behavior of notification.send
which seems overkill to me and no one would want to do that. It has too much
overlap with notification backends which I still think is the correct way in
addressing notification.send extensibility.
Brian Rosner
http://oebfare.com
http://twitter.com/brosner
--
You received this message because you are subscribed to the Google Groups
"Pinax Core Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pinax-core-dev?hl=en.