Commit cbb30c91 authored by Julien Muchembled's avatar Julien Muchembled

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
parent 7a245977
......@@ -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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment