Ejemplo n.º 1
0
 def __init__(self, code_review_comment, recipients, message_id=None):
     """Constructor."""
     self.code_review_comment = code_review_comment
     self.message = code_review_comment.message
     from_person = self.message.owner
     from_address = format_address(from_person.displayname,
                                   from_person.preferredemail.email)
     merge_proposal = code_review_comment.branch_merge_proposal
     BMPMailer.__init__(self,
                        self.message.subject,
                        None,
                        recipients,
                        merge_proposal,
                        from_address,
                        message_id=message_id)
     self.attachments = []
     original_email = self.code_review_comment.getOriginalEmail()
     if original_email is not None:
         # The original_email here is wrapped in a zope security proxy,
         # which is not helpful as there is no interface defined for
         # emails, so strip it off here.
         original_email = removeSecurityProxy(original_email)
         # The attachments for the code review comment are actually
         # library file aliases.
         display_aliases, other_aliases = (
             self.code_review_comment.getAttachments())
         include_attachments = set()
         for alias in display_aliases:
             include_attachments.add((alias.filename, alias.mimetype))
         for part in original_email.walk():
             if part.is_multipart():
                 continue
             filename = part.get_filename() or 'unnamed'
             if part['content-type'] is None:
                 content_type = 'application/octet-stream'
             else:
                 content_type = part['content-type']
             if (filename, content_type) in include_attachments:
                 payload = part.get_payload(decode=True)
                 self.attachments.append((payload, filename, content_type))
     self._generateBodyBits()
 def __init__(self, code_review_comment, recipients, message_id=None):
     """Constructor."""
     self.code_review_comment = code_review_comment
     self.message = code_review_comment.message
     from_person = self.message.owner
     from_address = format_address(
         from_person.displayname, from_person.preferredemail.email)
     merge_proposal = code_review_comment.branch_merge_proposal
     BMPMailer.__init__(
         self, self.message.subject, None, recipients, merge_proposal,
         from_address, message_id=message_id)
     self.attachments = []
     original_email = self.code_review_comment.getOriginalEmail()
     if original_email is not None:
         # The original_email here is wrapped in a zope security proxy,
         # which is not helpful as there is no interface defined for
         # emails, so strip it off here.
         original_email = removeSecurityProxy(original_email)
         # The attachments for the code review comment are actually
         # library file aliases.
         display_aliases, other_aliases = (
             self.code_review_comment.getAttachments())
         include_attachments = set()
         for alias in display_aliases:
             include_attachments.add((alias.filename, alias.mimetype))
         for part in original_email.walk():
             if part.is_multipart():
                 continue
             filename = part.get_filename() or 'unnamed'
             if part['content-type'] is None:
                 content_type = 'application/octet-stream'
             else:
                 content_type = part['content-type']
             if (filename, content_type) in include_attachments:
                 payload = part.get_payload(decode=True)
                 self.attachments.append(
                     (payload, filename, content_type))
     self._generateBodyBits()