- changed status to invalid
Improving pm_broadcast
Issue #64
invalid
While playing with the API function pm_broadcast
i noticed the recipients must be a list or a tuple. Nevertheless i spent 2h before finding that out (had to look at the source code).
But if you are excepting a list of users, forcing it to be a list or a tuple would mean having to convert the users Queryset returned by django to a list. It seems to be a bit of an overkill to me, why not just make it accept a Queryset only or as well?
def pm_broadcast(sender, recipients, subject, body='', skip_notification=False):
...
if not isinstance(recipients, (tuple, list)):
recipients = (recipients,)
...
Comments (1)
-
repo owner - Log in to comment
No the
recipients
parameter has not to be something in particular. But we want to support multiple types: a single instance, a list or a tuple of instances. Converting the single instance case to an iterable object is just a usual pattern (zen of python: "Special cases aren't special enough to break the rules") to bring all cases to a single one, here for a followingfor
loop processing.