filename can be None

This commit is contained in:
Benjamin Dauvergne 2012-05-10 11:39:32 +02:00
parent f66d9ca3ca
commit c1ff62c8c7
1 changed files with 3 additions and 2 deletions

View File

@ -107,14 +107,15 @@ In case of failure the following return value is returned:
except models.FileType.DoesNotExist:
content_errors.append('The subject "%s" does not match any known file type' % subject)
for part in mail.walk():
filename = self.decode_filename(part.get_filename(None))
filename = part.get_filename(None)
if part.get_content_type() == 'text/plain' and \
('Content-Disposition' not in part or 'inline' in part['Content-Disposition']):
charset = part.get_content_charset('us-ascii')
description = unicode(part.get_payload(decode=True), charset)
if filename:
attachments.append((filename, part.get_payload(decode=True)))
attachments.append((self.decode_filename(filename),
part.get_payload(decode=True)))
for email_address in all_recipients:
try:
user = auth_models.User.objects.get(email=email_address, delegations_by__isnull=True)