Commits

Anonymous committed 40baf9a Merge

Comments (0)

Files changed (2)

 
     @safe_call
     def _build_query(self):
+        for query in self.gae_query:
+            query.Order(*self.gae_ordering)
         if len(self.gae_query) > 1:
-            for i in self.gae_query:
-                i.Order(*self.gae_ordering)
             return MultiQuery(self.gae_query, self.gae_ordering)
-        query = self.gae_query[0]
-        query.Order(*self.gae_ordering)
-        return query
+        return self.gae_query[0]
 
     def get_matching_pk(self, low_mark=0, high_mark=None):
         if not self.pk_filters:
         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
+            # Must be populated with (filename, filecontents) tuples
+            attachments = []
+            for attachment in message.attachments:
+                if isinstance(attachment, MIMEBase):
+                    attachments.append((attachment.get_filename(),
+                                        attachment.get_payload(decode=True)))
+                else:
+                    gmsg.attachments.append((a[0], a[1]))
+            gmsg.attachments = attachments
+        # Look for HTML alternative content
+        if isinstance(message, EmailMultiAlternatives):
             for content, mimetype in message.alternatives:
                 if mimetype == 'text/html':
                     gmsg.html = content