From bbcd7d6991afb7431e4f60790d6809aa41ab85b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl>
Date: Fri, 26 Jan 2007 15:28:48 +0000
Subject: [PATCH] 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
---
 product/ERP5/Tool/ContributionTool.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Tool/ContributionTool.py b/product/ERP5/Tool/ContributionTool.py
index b2bd116c72..b493d74a47 100644
--- a/product/ERP5/Tool/ContributionTool.py
+++ b/product/ERP5/Tool/ContributionTool.py
@@ -26,9 +26,10 @@
 #
 ##############################################################################
 
+import cStringIO
+import pdb
 import re
 import string
-import pdb
 
 from AccessControl import ClassSecurityInfo, getSecurityManager
 from Globals import InitializeClass, DTMLFile
@@ -145,11 +146,21 @@ class ContributionTool(BaseTool):
       return BaseTool.newContent(self, id=id, portal_type=portal_type, temp_object=1, **kw)
 
     # Try to find the file_name
+    file_name = None
+    # check if file was provided
     file = kw.get('file', None)
     if file is not None:
       file_name = file.filename
     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 portal_type is not None and portal_type != '':
-- 
2.30.9