[Erp5-report] r41121 nicolas - /erp5/trunk/products/ERP5/Document/File.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Dec 4 15:47:58 CET 2010


Author: nicolas
Date: Sat Dec  4 15:47:58 2010
New Revision: 41121

URL: http://svn.erp5.org?rev=41121&view=rev
Log:
File._edit assume that file property is a FileObject with filename attribute.
But through Contribution Tool, file is just a StringIO object without filename attribute.
As filename is provided in kw, we fallback on kw.get('filename') to get the value
of filename instead of reading it from file.

Modified:
    erp5/trunk/products/ERP5/Document/File.py

Modified: erp5/trunk/products/ERP5/Document/File.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/File.py?rev=41121&r1=41120&r2=41121&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/File.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/File.py [utf8] Sat Dec  4 15:47:58 2010
@@ -106,6 +106,11 @@ class File(Document, CMFFile):
       filename = getattr(file, 'filename', None)
       # if file field is empty(no file is uploaded),
       # filename is empty string.
+      if not filename:
+        # settings the filename before calling
+        # _setFile is required to setup the content_type
+        # property
+        filename = kw.get('filename')
       if filename:
         self._setFilename(filename)
       if self._isNotEmpty(file):



More information about the Erp5-report mailing list