diff libervia/server/pages.py @ 1392:e11a71a08a48

pages: fix `getPostedData` when a single value is requested and a list is used
author Goffi <goffi@goffi.org>
date Sat, 27 Feb 2021 21:03:08 +0100
parents 3e482795630c
children d9a328ddef9c
line wrap: on
line diff
--- a/libervia/server/pages.py	Sat Feb 27 21:00:48 2021 +0100
+++ b/libervia/server/pages.py	Sat Feb 27 21:03:08 2021 +0100
@@ -1242,7 +1242,7 @@
         raise failure.Failure(exceptions.CancelError("HTTP redirection is used"))
 
     def redirectOrContinue(self, request, redirect_arg="redirect_url"):
-        """helper method to redirect a page to an url given as arg
+        """Helper method to redirect a page to an url given as arg
 
         if the arg is not present, the page will continue normal workflow
         @param request(server.Request): current HTTP request
@@ -1540,9 +1540,6 @@
         #         double unquote
         if isinstance(keys, str):
             keys = [keys]
-            get_first = True
-        else:
-            get_first = False
 
         keys = [k.encode('utf-8') for k in keys]
 
@@ -1561,7 +1558,10 @@
                     else:
                         ret.append(None)
 
-        return ret[0] if get_first else ret
+        if len(keys) == 1:
+            return ret[0]
+        else:
+            return ret
 
     def getAllPostedData(self, request, except_=(), multiple=True):
         """get all posted data
@@ -1587,7 +1587,7 @@
         return ret
 
     def getProfile(self, request):
-        """helper method to easily get current profile
+        """Helper method to easily get current profile
 
         @return (unicode, None): current profile
             None if no profile session is started
@@ -1596,7 +1596,7 @@
         return sat_session.profile
 
     def getJid(self, request):
-        """helper method to easily get current jid
+        """Helper method to easily get current jid
 
         @return: current jid
         """
@@ -1605,7 +1605,7 @@
 
 
     def getRData(self, request):
-        """helper method to get request data dict
+        """Helper method to get request data dict
 
         this dictionnary if for the request only, it is not saved in session
         It is mainly used to pass data between pages/methods called during request