changeset 959:968eda9e982a

server: added getAllPostedData
author Goffi <goffi@goffi.org>
date Sun, 24 Sep 2017 16:50:39 +0200
parents 3c81203840a4
children e59edcae4c18
files src/server/server.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/server/server.py	Sun Sep 24 16:49:23 2017 +0200
+++ b/src/server/server.py	Sun Sep 24 16:50:39 2017 +0200
@@ -1750,6 +1750,23 @@
 
         return ret[0] if get_first else ret
 
+    def getAllPostedData(self, request, except_=()):
+        """get all posted data
+
+        @param request(server.Request): request linked to the session
+        @param except_(iterable[unicode]): key of values to ignore
+            csrf_token will always be ignored
+        @return (dict[unicode, list[unicode]]): post values
+        """
+        except_ = tuple(except_) + (u'csrf_token',)
+        ret = {}
+        for key, values in request.args.iteritems():
+            key = urllib.unquote(key).decode('utf-8')
+            if key in except_:
+                continue
+            ret[key] = [urllib.unquote(v).decode('utf-8') for v in values]
+        return ret
+
     def getProfile(self, request):
         """helper method to easily get current profile