Author: brosner
Date: Sun Sep 28 21:48:00 2008
New Revision: 38

Added:
    trunk/devproject/emailconfirmation/utils.py
Modified:
    trunk/devproject/emailconfirmation/models.py

Log:
Improved the optional import of django-mailer to rely on INSTALLED_APPS  
instead of the PYTHONPATH. This also takes the priority kwarg into  
consideration which is new to django-mailer.

Modified: trunk/devproject/emailconfirmation/models.py
==============================================================================
--- trunk/devproject/emailconfirmation/models.py        (original)
+++ trunk/devproject/emailconfirmation/models.py        Sun Sep 28 21:48:00 2008
@@ -2,20 +2,15 @@
  from random import random
  import sha

+from django.conf import settings
  from django.db import models, IntegrityError
  from django.template.loader import render_to_string
  from django.core.urlresolvers import reverse
  from django.contrib.sites.models import Site
-
-# favour django-mailer but fall back to django.core.mail
-try:
-    from mailer import send_mail
-except ImportError:
-    from django.core.mail import send_mail
-
-from django.conf import settings
-
  from django.contrib.auth.models import User
+
+from emailconfirmation.utils import get_send_mail
+send_mail = get_send_mail()

  # this code based in-part on django-registration


Added: trunk/devproject/emailconfirmation/utils.py
==============================================================================
--- (empty file)
+++ trunk/devproject/emailconfirmation/utils.py Sun Sep 28 21:48:00 2008
@@ -0,0 +1,16 @@
+
+def get_send_mail():
+    """
+    A function to return a send_mail function suitable for use in the app.  
It
+    deals with incompatibilities between signatures.
+    """
+    from django.db.models.loading import get_app
+    # favour django-mailer but fall back to django.core.mail
+    if get_app("mailer", emptyOK=True):
+        from mailer import send_mail
+    else:
+        from django.core.mail import send_mail as _send_mail
+        def send_mail(*args, **kwargs):
+            del kwargs["priority"]
+            return _send_mail(*args, **kwargs)
+    return send_mail
\ No newline at end of file

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