Commits

Waldemar Kornewald committed 85df165

renamed email backend module to "mail" since Django seems to use that naming convention

Comments (0)

Files changed (3)

email.py

-from django.core.mail.backends.base import BaseEmailBackend
-from django.core.mail import EmailMultiAlternatives
-from django.core.exceptions import ImproperlyConfigured
-
-from google.appengine.api import mail as aeemail
-
-def _send_deferred(message):
-    message.send()
-
-class EmailBackend(BaseEmailBackend):
-    can_defer = False
-
-    def send_messages(self, email_messages):
-        num_sent = 0
-        for message in email_messages:
-            if self._send(message):
-                num_sent += 1
-        return num_sent
-
-    def _copy_message(self, message):
-        """Create and return App Engine EmailMessage class from message."""
-        gmsg = aeemail.EmailMessage(sender=message.from_email,
-                                    to=message.to,
-                                    subject=message.subject,
-                                    body=message.body)
-        if message.extra_headers.get('Reply-To', None):
-            gmsg.reply_to = message.extra_headers['Reply-To']
-        if message.bcc:
-            gmsg.bcc = list(message.bcc)
-        if message.attachments:
-            gmsg.attachments = [(a[0], a[1]) for a in message.attachments]
-        if isinstance(message, EmailMultiAlternatives):  # look for HTML
-            for content, mimetype in message.alternatives:
-                if mimetype == 'text/html':
-                    gmsg.html = content
-                    break
-        return gmsg
-
-    def _send(self, message):
-        try:
-            message = self._copy_message(message)
-        except (ValueError, aeemail.InvalidEmailError), err:
-            import logging
-            logging.warn(err)
-            if not self.fail_silently:
-                raise
-            return False
-        if self.can_defer:
-            self._defer_message(message)
-            return True
-        try:
-            message.send()
-        except aeemail.Error:
-            if not self.fail_silently:
-                raise
-            return False
-        return True
-
-    def _defer_message(self, message):
-        from google.appengine.ext import deferred
-        deferred.defer(_send_deferred, message)
-
-class AsyncEmailBackend(EmailBackend):
-    can_defer = True
+from django.core.mail.backends.base import BaseEmailBackend
+from django.core.mail import EmailMultiAlternatives
+from django.core.exceptions import ImproperlyConfigured
+
+from google.appengine.api import mail as aeemail
+
+def _send_deferred(message):
+    message.send()
+
+class EmailBackend(BaseEmailBackend):
+    can_defer = False
+
+    def send_messages(self, email_messages):
+        num_sent = 0
+        for message in email_messages:
+            if self._send(message):
+                num_sent += 1
+        return num_sent
+
+    def _copy_message(self, message):
+        """Create and return App Engine EmailMessage class from message."""
+        gmsg = aeemail.EmailMessage(sender=message.from_email,
+                                    to=message.to,
+                                    subject=message.subject,
+                                    body=message.body)
+        if message.extra_headers.get('Reply-To', None):
+            gmsg.reply_to = message.extra_headers['Reply-To']
+        if message.bcc:
+            gmsg.bcc = list(message.bcc)
+        if message.attachments:
+            gmsg.attachments = [(a[0], a[1]) for a in message.attachments]
+        if isinstance(message, EmailMultiAlternatives):  # look for HTML
+            for content, mimetype in message.alternatives:
+                if mimetype == 'text/html':
+                    gmsg.html = content
+                    break
+        return gmsg
+
+    def _send(self, message):
+        try:
+            message = self._copy_message(message)
+        except (ValueError, aeemail.InvalidEmailError), err:
+            import logging
+            logging.warn(err)
+            if not self.fail_silently:
+                raise
+            return False
+        if self.can_defer:
+            self._defer_message(message)
+            return True
+        try:
+            message.send()
+        except aeemail.Error:
+            if not self.fail_silently:
+                raise
+            return False
+        return True
+
+    def _defer_message(self, message):
+        from google.appengine.ext import deferred
+        deferred.defer(_send_deferred, message)
+
+class AsyncEmailBackend(EmailBackend):
+    can_defer = True
     },
 }
 
-EMAIL_BACKEND = 'djangoappengine.email.AsyncEmailBackend'
+EMAIL_BACKEND = 'djangoappengine.mail.AsyncEmailBackend'
 
 FILE_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024
 FILE_UPLOAD_HANDLERS = (
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.