diff MoinMoin/action/AttachFile.py @ 4432:253a1e691b19

fix saving of drawings to use WSGI/werkzeug API correctly
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 24 Nov 2008 00:24:45 +0100
parents 8982d8226218
children a499a137ecf5
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Sat Nov 22 22:48:42 2008 +0100
+++ b/MoinMoin/action/AttachFile.py	Mon Nov 24 00:24:45 2008 +0100
@@ -588,8 +588,13 @@
     if not request.user.may.write(pagename):
         return _('You are not allowed to save a drawing on this page.')
 
+    file_upload = request.files.get('filepath')
+    if not file_upload:
+        # This might happen when trying to upload file names
+        # with non-ascii characters on Safari.
+        return _("No file content. Delete non ASCII characters from the file name and try again.")
+
     filename = request.form['filename']
-    filecontent = request.form['filepath']
 
     basepath, basename = os.path.split(filename)
     basename, ext = os.path.splitext(basename)
@@ -600,10 +605,10 @@
 
     if ext == '.draw':
         _addLogEntry(request, 'ATTDRW', pagename, basename + ext)
-        filecontent = filecontent.read() # read file completely into memory
+        filecontent = file_upload.stream.read() # read file completely into memory
         filecontent = filecontent.replace("\r", "")
     elif ext == '.map':
-        filecontent = filecontent.read() # read file completely into memory
+        filecontent = file_upload.stream.read() # read file completely into memory
         filecontent = filecontent.strip()
 
     if filecontent: