comparison src/server/server.py @ 959:968eda9e982a

server: added getAllPostedData
author Goffi <goffi@goffi.org>
date Sun, 24 Sep 2017 16:50:39 +0200
parents 67bf14c91d5c
children 22fe06569b1a
comparison
equal deleted inserted replaced
958:3c81203840a4 959:968eda9e982a
1748 except StopIteration: 1748 except StopIteration:
1749 return KeyError(key) 1749 return KeyError(key)
1750 1750
1751 return ret[0] if get_first else ret 1751 return ret[0] if get_first else ret
1752 1752
1753 def getAllPostedData(self, request, except_=()):
1754 """get all posted data
1755
1756 @param request(server.Request): request linked to the session
1757 @param except_(iterable[unicode]): key of values to ignore
1758 csrf_token will always be ignored
1759 @return (dict[unicode, list[unicode]]): post values
1760 """
1761 except_ = tuple(except_) + (u'csrf_token',)
1762 ret = {}
1763 for key, values in request.args.iteritems():
1764 key = urllib.unquote(key).decode('utf-8')
1765 if key in except_:
1766 continue
1767 ret[key] = [urllib.unquote(v).decode('utf-8') for v in values]
1768 return ret
1769
1753 def getProfile(self, request): 1770 def getProfile(self, request):
1754 """helper method to easily get current profile 1771 """helper method to easily get current profile
1755 1772
1756 @return (unicode, None): current profile 1773 @return (unicode, None): current profile
1757 None if no profile session is started 1774 None if no profile session is started