Author: brosner
Date: Mon Oct 13 12:41:19 2008
New Revision: 104
Modified:
trunk/notification/models.py
Log:
Use None for default values in function signatures to avoid mistakes and
follow best practices.
Modified: trunk/notification/models.py
==============================================================================
--- trunk/notification/models.py (original)
+++ trunk/notification/models.py Mon Oct 13 12:41:19 2008
@@ -225,7 +225,7 @@
'notification/%s' % format), context_instance=context)
return format_templates
-def send(users, label, extra_context={}, on_site=True):
+def send(users, label, extra_context=None, on_site=True):
"""
Creates a new notice.
@@ -239,6 +239,9 @@
You can pass in on_site=False to prevent the notice emitted from being
displayed on the site.
"""
+ if extra_context is None:
+ extra_context = {}
+
notice_type = NoticeType.objects.get(label=label)
current_site = Site.objects.get_current()
@@ -299,7 +302,14 @@
# reset environment to original language
activate(current_language)
-def queue(users, label, extra_context={}, on_site=True):
+def queue(users, label, extra_context=None, on_site=True):
+ """
+ A basic interface around send. Checks NOTIFICATION_QUEUE_ALL to
determine
+ behavior, but queue function argument can override global behavior on a
+ per call basis.
+ """
+ if extra_context is None:
+ extra_context = {}
if isinstance(users, QuerySet):
users = [row["pk"] for row in users.values("pk")]
else:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---