Mercurial > libervia-web
comparison src/server/pages.py @ 1009:b57f86bc1177
pages: added "multiple" argument to getAllPostedData
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Jan 2018 22:00:28 +0100 |
parents | 05cc33d8e328 |
children | 4de970de87d7 |
comparison
equal
deleted
inserted
replaced
1008:1593e00078d2 | 1009:b57f86bc1177 |
---|---|
820 except StopIteration: | 820 except StopIteration: |
821 raise KeyError(key) | 821 raise KeyError(key) |
822 | 822 |
823 return ret[0] if get_first else ret | 823 return ret[0] if get_first else ret |
824 | 824 |
825 def getAllPostedData(self, request, except_=()): | 825 def getAllPostedData(self, request, except_=(), multiple=True): |
826 """get all posted data | 826 """get all posted data |
827 | 827 |
828 @param request(server.Request): request linked to the session | 828 @param request(server.Request): request linked to the session |
829 @param except_(iterable[unicode]): key of values to ignore | 829 @param except_(iterable[unicode]): key of values to ignore |
830 csrf_token will always be ignored | 830 csrf_token will always be ignored |
831 @param multiple(bool): if False, only the first values are returned | |
831 @return (dict[unicode, list[unicode]]): post values | 832 @return (dict[unicode, list[unicode]]): post values |
832 """ | 833 """ |
833 except_ = tuple(except_) + (u'csrf_token',) | 834 except_ = tuple(except_) + (u'csrf_token',) |
834 ret = {} | 835 ret = {} |
835 for key, values in request.args.iteritems(): | 836 for key, values in request.args.iteritems(): |
836 key = urllib.unquote(key).decode('utf-8') | 837 key = urllib.unquote(key).decode('utf-8') |
837 if key in except_: | 838 if key in except_: |
838 continue | 839 continue |
839 ret[key] = [urllib.unquote(v).decode('utf-8') for v in values] | 840 if not multiple: |
841 ret[key] = urllib.unquote(values[0]).decode('utf-8') | |
842 else: | |
843 ret[key] = [urllib.unquote(v).decode('utf-8') for v in values] | |
840 return ret | 844 return ret |
841 | 845 |
842 def getProfile(self, request): | 846 def getProfile(self, request): |
843 """helper method to easily get current profile | 847 """helper method to easily get current profile |
844 | 848 |