Mercurial > libervia-web
changeset 1009:b57f86bc1177
pages: added "multiple" argument to getAllPostedData
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Jan 2018 22:00:28 +0100 |
parents | 1593e00078d2 |
children | 4de970de87d7 |
files | src/server/pages.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/server/pages.py Fri Jan 12 18:03:34 2018 +0100 +++ b/src/server/pages.py Fri Jan 12 22:00:28 2018 +0100 @@ -822,12 +822,13 @@ return ret[0] if get_first else ret - def getAllPostedData(self, request, except_=()): + def getAllPostedData(self, request, except_=(), multiple=True): """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 + @param multiple(bool): if False, only the first values are returned @return (dict[unicode, list[unicode]]): post values """ except_ = tuple(except_) + (u'csrf_token',) @@ -836,7 +837,10 @@ key = urllib.unquote(key).decode('utf-8') if key in except_: continue - ret[key] = [urllib.unquote(v).decode('utf-8') for v in values] + if not multiple: + ret[key] = urllib.unquote(values[0]).decode('utf-8') + else: + ret[key] = [urllib.unquote(v).decode('utf-8') for v in values] return ret def getProfile(self, request):