changeset 625:f4e63b74b969

FormSubmit: adapt to werkzeug MultiDict
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Mar 2013 17:47:30 +0100
parents bdebdc59b057
children f64779d5d500
files data/plugin/action/submitbase.py data/plugin/action/submitcsv.py data/plugin/action/submitemail.py
diffstat 3 files changed, 11 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/submitbase.py	Mon Mar 25 17:28:25 2013 +0100
+++ b/data/plugin/action/submitbase.py	Mon Mar 25 17:47:30 2013 +0100
@@ -75,13 +75,13 @@
         # file upload is present
         if "file" in request.form:
             self.attachFile = request.form.get("file__filename__")
-            self.attachContent = request.form.get("file")[0]
-            self.attachLabel = request.form.get("uploadlabel")[0]
+            self.attachContent = request.form.get("file")
+            self.attachLabel = request.form.get("uploadlabel")
             self.attachLabel = self.attachLabel.encode('utf-8')
             
         # page where all submited data will be stored
         if "targetpage" in request.form:
-            targetpage = request.form.get("targetpage")[0]
+            targetpage = request.form.get("targetpage")
             page = Page(self.request, targetpage)
             if page.isStandardPage(False):
                 self.targetpage = targetpage
@@ -192,10 +192,10 @@
         pagename = self.pagename
         request = self.request
         
-        arena = request.form.get('arena', ['Page.py'])[0]
+        arena = request.form.get('arena', 'Page.py')
         if arena == 'Page.py':
             arena = Page(request, pagename)
-        key = request.form.get('key', ['text_html'])[0]
+        key = request.form.get('key', 'text_html')
     
         # Remove cache entry (if exists), and send the page
         from MoinMoin import caching
@@ -204,14 +204,8 @@
         
     def _exclude_metadata(self, form):
         """ Filter all form metadata and returns only data send by user """
-        fields = copy.deepcopy(form)
-        
-        for label, value in form.iteritems():
-            if self.metadata.count(label) > 0:
-                del fields[label]
-            else:
-                fields[label] = value[0]
-        
+        fields = dict([(k, v) for k, v in form.to_dict().iteritems()
+                       if k not in self.metadata])
         return fields
             
     def _sort_fields(self, fields, form):
@@ -224,7 +218,8 @@
         values = []                    
         
         if 'labels' in form:
-            _labels = form.get('labels')[0].split(";")
+            _labels = form.get('labels').split(";")
+            print _labels
             for label in _labels:
                 label = label.encode('utf-8')
                 labels.append(label)
--- a/data/plugin/action/submitcsv.py	Mon Mar 25 17:28:25 2013 +0100
+++ b/data/plugin/action/submitcsv.py	Mon Mar 25 17:47:30 2013 +0100
@@ -35,7 +35,7 @@
         self.targetFile = ""
         
         if "targetfile" in request.form:
-            self.targetFile = request.form.get("targetfile")[0]
+            self.targetFile = request.form.get("targetfile")
         else:
             self.targetFile = u"list.csv"
         
--- a/data/plugin/action/submitemail.py	Mon Mar 25 17:28:25 2013 +0100
+++ b/data/plugin/action/submitemail.py	Mon Mar 25 17:47:30 2013 +0100
@@ -30,7 +30,7 @@
         self.subject = "Moinmoin mail"
         
         if "targetemail" in request.form:
-            self.targetemail = request.form.get("targetemail")[0]
+            self.targetemail = request.form.get("targetemail")
         
     def build_content(self):
         """ Builds simple 'label: value' string """