Author: leidel
Date: Thu Feb 5 07:11:42 2009
New Revision: 61
Modified:
trunk/mailer/__init__.py
Log:
Fixed issue with module level Django import that can break installation in
virtualenvs
Modified: trunk/mailer/__init__.py
==============================================================================
--- trunk/mailer/__init__.py (original)
+++ trunk/mailer/__init__.py Thu Feb 5 07:11:42 2009
@@ -1,5 +1,3 @@
-from django.utils.encoding import force_unicode
-
VERSION = (0, 1, 0, "pre")
def get_version():
@@ -17,13 +15,18 @@
"deferred": "4",
}
+def force_unicode_wrapper(text):
+ """wraps force_unicode to prevent ImportError during installation"""
+ from django.utils.encoding import force_unicode
+ return force_unicode(text)
+
# replacement for django.core.mail.send_mail
def send_mail(subject, message, from_email, recipient_list,
priority="medium",
fail_silently=False, auth_user=None, auth_password=None):
from mailer.models import Message
# need to do this in case subject used lazy version of ugettext
- subject = force_unicode(subject)
+ subject = force_unicode_wrapper(subject)
priority = PRIORITY_MAPPING[priority]
for to_address in recipient_list:
Message(to_address=to_address,
@@ -39,7 +42,7 @@
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),
+ subject=settings.EMAIL_SUBJECT_PREFIX +
force_unicode_wrapper(subject),
message_body=message,
priority=priority).save()
@@ -50,6 +53,6 @@
for name, to_address in settings.MANAGERS:
Message(to_address=to_address,
from_address=settings.SERVER_EMAIL,
- subject=settings.EMAIL_SUBJECT_PREFIX +
force_unicode(subject),
+ subject=settings.EMAIL_SUBJECT_PREFIX +
force_unicode_wrapper(subject),
message_body=message,
priority=priority).save()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---