Exemple #1
0
    def add_payload(self, payload):
        """Add the given payload to the current payload.

        If the current payload is empty, then the current payload will be made
        a scalar, set to the given value.

        Note: This method is deprecated.  Use .attach() instead.
        """
        warnings.warn('add_payload() is deprecated, use attach() instead.',
                      DeprecationWarning, 2)
        if self._payload is None:
            self._payload = payload
        elif isinstance(self._payload, ListType):
            self._payload.append(payload)
        elif self.get_main_type() not in (None, 'multipart'):
            raise Errors.MultipartConversionError(
                'Message main content type must be "multipart" or missing')
        else:
            self._payload = [self._payload, payload]
 def attach(self, payload):
     # The public API prohibits attaching multiple subparts to MIMEBase
     # derived subtypes since none of them are, by definition, of content
     # type multipart/*
     raise Errors.MultipartConversionError(
         'Cannot attach additional subparts to non-multipart/*')