Tony Mack | 050ca93 | 2013-04-08 15:08:02 -0400 | [diff] [blame] | 1 | import ast |
Tony Mack | 82aa4f0 | 2013-04-08 17:45:42 -0400 | [diff] [blame] | 2 | from django.http.request import QueryDict |
Tony Mack | be12a20 | 2013-04-08 15:07:20 -0400 | [diff] [blame] | 3 | |
| 4 | def parse_request(request): |
| 5 | d = {} |
Tony Mack | 82aa4f0 | 2013-04-08 17:45:42 -0400 | [diff] [blame] | 6 | if isinstance(request, unicode): |
| 7 | d = ast.literal_eval(request) |
| 8 | elif isinstance(request, QueryDict): |
| 9 | for (k,v) in request.items(): |
| 10 | d[k] = ast.literal_eval(v) |
Tony Mack | 1daa544 | 2013-04-08 19:39:57 -0400 | [diff] [blame] | 11 | elif isinstance(request, dict): |
| 12 | d = request |
| 13 | |
Tony Mack | 1e09659 | 2013-04-08 15:11:38 -0400 | [diff] [blame] | 14 | return d |