# HG changeset patch # User Goffi # Date 1614456188 -3600 # Node ID e11a71a08a488034b55811ff753ce3ee6d1d463a # Parent fc20818a52662f5d4f0d3e2c86b59ccc7cd7782a pages: fix `getPostedData` when a single value is requested and a list is used diff -r fc20818a5266 -r e11a71a08a48 libervia/server/pages.py --- 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