Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 211

Show
Ignore:
Timestamp:
05/24/05 15:05:48
Author:
peterhunt
Message:

- fix for parse_qs #141
- added autoreload for the "dev" server env

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttpserver.py

    r202 r211  
    2929import cpg, sys, threading, SocketServer, _cphttptools 
    3030import BaseHTTPServer, socket, Queue, _cputil 
     31from lib import autoreload 
    3132 
    3233def stop(): 
     
    3435 
    3536def start(): 
     37    if cpg.config.get("server.env") == "dev": 
     38        autoreload.main(_start) 
     39    else: 
     40        _start() 
     41 
     42def _start(): 
    3643    """ Prepare the HTTP server and then run it """ 
    3744 
  • trunk/cherrypy/_cphttptools.py

    r202 r211  
    5252    cpg.request.filenameMap = {} 
    5353    cpg.request.fileTypeMap = {} 
    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] 
    8466 
    8567def cookHeaders(clientAddress, remoteHost, headers, requestLine): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets