Commit bbcd7d69 authored by Bartek Górny's avatar Bartek Górny

provide for file name and data given in separate strings instead of a file...

provide for file name and data given in separate strings instead of a file object (for email ingestor)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12400 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8ebdca43
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
# #
############################################################################## ##############################################################################
import cStringIO
import pdb
import re import re
import string import string
import pdb
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo, getSecurityManager
from Globals import InitializeClass, DTMLFile from Globals import InitializeClass, DTMLFile
...@@ -145,11 +146,21 @@ class ContributionTool(BaseTool): ...@@ -145,11 +146,21 @@ class ContributionTool(BaseTool):
return BaseTool.newContent(self, id=id, portal_type=portal_type, temp_object=1, **kw) return BaseTool.newContent(self, id=id, portal_type=portal_type, temp_object=1, **kw)
# Try to find the file_name # Try to find the file_name
file_name = None
# check if file was provided
file = kw.get('file', None) file = kw.get('file', None)
if file is not None: if file is not None:
file_name = file.filename file_name = file.filename
else: else:
file_name = None # some channels supply data and file name separately
# we have to build an object
data = kw.get('data', None)
if data is not None:
file_name = kw.get('file_name', None)
if file_name is not None:
file = cStringIO.StringIO()
file.write(data)
file.seek(0)
# If the portal_type was provided, we can go faster # If the portal_type was provided, we can go faster
if portal_type is not None and portal_type != '': if portal_type is not None and portal_type != '':
......
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