Author: brosner
Date: Sun Sep 28 21:18:06 2008
New Revision: 38

Modified:
    trunk/mailerdev/mailer/__init__.py

Log:
Exposed priority on the public API for send_mail and mail_admins.

Modified: trunk/mailerdev/mailer/__init__.py
==============================================================================
--- trunk/mailerdev/mailer/__init__.py  (original)
+++ trunk/mailerdev/mailer/__init__.py  Sun Sep 28 21:18:06 2008
@@ -1,23 +1,36 @@
  from django.utils.encoding import force_unicode
  from django.conf import settings
-from mailer.models import Message

-# replacement for django.core.mail.send_mail
+PRIORITY_MAPPING = {
+    "high": "1",
+    "medium": "2",
+    "low": "3",
+    "deferred": "4",
+}

-def send_mail(subject, message, from_address, to_addresses):
+# replacement for django.core.mail.send_mail

+def send_mail(subject, message, from_address, to_addresses,  
priority="medium"):
+    from mailer.models import Message
      # need to do this in case subject used lazy version of ugettext
      subject = force_unicode(subject)
-
+    priority = PRIORITY_MAPPING[priority]
      for to_address in to_addresses:
-        Message(to_address=to_address, from_address=from_address,  
subject=subject, message_body=message).save()
+        Message(to_address=to_address,
+                from_address=from_address,
+                subject=subject,
+                message_body=message,
+                priority=priority).save()

-def mail_admins(subject, message, fail_silently=False):
+def mail_admins(subject, message, fail_silently=False, priority="medium"):
+    from mailer.models import Message
+    priority = PRIORITY_MAPPING[priority]
      for name, to_address in settings.ADMINS:
          Message(to_address=to_address,
                  from_address=settings.SERVER_EMAIL,
                  subject=settings.EMAIL_SUBJECT_PREFIX +  
force_unicode(subject),
-                message_body=message).save()
+                message_body=message,
+                priority=priority).save()

  if getattr(settings, 'MAILER_FOR_CHASH_EMAILS', False):
      from django.core.handlers import base

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to