From cbb30c91232ea5bd54c509e20099cb6491523a82 Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Tue, 2 Sep 2008 08:47:48 +0000
Subject: [PATCH] Allow empty files to be added through the 'data' parameter.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23330 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/MailTemplates/MTMultipart.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/product/MailTemplates/MTMultipart.py b/product/MailTemplates/MTMultipart.py
index da148ae8ed..3e1df752d5 100644
--- a/product/MailTemplates/MTMultipart.py
+++ b/product/MailTemplates/MTMultipart.py
@@ -42,15 +42,15 @@ class MTMultipart(MIMEMultipart):
     security.declarePublic('add_file')
     def add_file(self,theFile=None,data=None,filename=None,content_type=None):
         "add a Zope file or Image to ourselves as an attachment"
-        if theFile and data:
+        if theFile and data is not None:
             raise TypeError(
                 'A file-like object was passed as well as data to create a file'
                 )
-        if (data or filename) and not (data and filename):
+        if (data is None) != (not filename):
             raise TypeError(
                 'Both data and filename must be specified'
                 )
-        if data:
+        if data is not None:
             if content_type is None:
                 content_type, enc=guess_content_type(filename, data)
         elif isinstance(theFile,File):
-- 
2.30.9