| 54 | | i = cpg.request.path.find('?') |
|---|
| 55 | | if i != -1: |
|---|
| 56 | | # Parse parameters from URL |
|---|
| 57 | | if cpg.request.path[i+1:]: |
|---|
| 58 | | k = cpg.request.path[i+1:].find('?') |
|---|
| 59 | | if k != -1: |
|---|
| 60 | | j = cpg.request.path[:k].rfind('=') |
|---|
| 61 | | if j != -1: |
|---|
| 62 | | cpg.request.path = cpg.request.path[:j+1] + \ |
|---|
| 63 | | urllib.quote_plus(cpg.request.path[j+1:]) |
|---|
| 64 | | for paramStr in cpg.request.path[i+1:].split('&'): |
|---|
| 65 | | sp = paramStr.split('=') |
|---|
| 66 | | if len(sp) > 2: |
|---|
| 67 | | j = paramStr.find('=') |
|---|
| 68 | | sp = (paramStr[:j], paramStr[j+1:]) |
|---|
| 69 | | if len(sp) == 2: |
|---|
| 70 | | key, value = sp |
|---|
| 71 | | value = urllib.unquote_plus(value) |
|---|
| 72 | | if cpg.request.paramMap.has_key(key): |
|---|
| 73 | | # Already has a value: make a list out of it |
|---|
| 74 | | if type(cpg.request.paramMap[key]) == type([]): |
|---|
| 75 | | # Already is a list: append the new value to it |
|---|
| 76 | | cpg.request.paramMap[key].append(value) |
|---|
| 77 | | else: |
|---|
| 78 | | # Only had one value so far: start a list |
|---|
| 79 | | cpg.request.paramMap[key] = [cpg.request.paramMap[key], value] |
|---|
| 80 | | else: |
|---|
| 81 | | cpg.request.paramMap[key] = value |
|---|
| 82 | | cpg.request.queryString = cpg.request.path[i+1:] |
|---|
| 83 | | cpg.request.path = cpg.request.path[:i] |
|---|
| | 54 | # From http://www.cherrypy.org/ticket/141/ |
|---|
| | 55 | # find the queryString, or set it to "" if not found |
|---|
| | 56 | if "?" in cpg.request.path: |
|---|
| | 57 | cpg.request.path, cpg.request.queryString = cpg.request.path.split("?",1) |
|---|
| | 58 | else: |
|---|
| | 59 | cpg.request.path, cpg.request.queryString = cpg.request.path, "" |
|---|
| | 60 | |
|---|
| | 61 | # build a paramMap dictionary from queryString |
|---|
| | 62 | pm = cpg.request.paramMap = cgi.parse_qs(cpg.request.queryString, True) |
|---|
| | 63 | for key, val in pm.items(): |
|---|
| | 64 | if len(val) == 1: |
|---|
| | 65 | pm[key] = val[0] |
|---|