changeset 4430:97ecf28b5969

fix Load action to use WSGI/werkzeug API correctly
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 22 Nov 2008 16:57:05 +0100
parents 574644cfc6d2
children 436048b821a5
files MoinMoin/action/Load.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/Load.py	Thu Nov 20 21:59:43 2008 +0100
+++ b/MoinMoin/action/Load.py	Sat Nov 22 16:57:05 2008 +0100
@@ -39,7 +39,13 @@
         comment = form.get('comment', u'')
         comment = wikiutil.clean_input(comment)
 
-        filename = form.get('file__filename__')
+        file_upload = request.files.get('file')
+        if not file_upload:
+            # This might happen when trying to upload file names
+            # with non-ascii characters on Safari.
+            return False, _("No file content. Delete non ASCII characters from the file name and try again.")
+
+        filename = file_upload.filename
         rename = form.get('rename', '').strip()
         if rename:
             target = rename
@@ -50,9 +56,7 @@
         target = wikiutil.clean_input(target)
 
         if target:
-            filecontent = form['file']
-            if hasattr(filecontent, 'read'): # a file-like object
-                filecontent = filecontent.read() # XXX reads complete file into memory!
+            filecontent = file_upload.stream.read() # XXX reads complete file into memory!
             filecontent = wikiutil.decodeUnknownInput(filecontent)
 
             self.pagename = target