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

Changeset 1130

Show
Ignore:
Timestamp:
06/09/06 03:00:45
Author:
fumanchu
Message:

Fix for #490 (InternalRedirect? should auto-detect params). Removed the "params" arg from InternalRedirect?; set cherrypy.request.params directly (before raising InternalRedirect?) instead.

Files:

Legend:

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

    r1128 r1130  
    44import sys 
    55import traceback 
    6 import urllib 
    76import urlparse 
    87 
     
    2019    """Exception raised when processing should be handled by a different path. 
    2120     
    22     If you supply 'params', it will be used to re-populate params. 
    23     If 'params' is a dict, it will be used directly. 
    24     If 'params' is a string, it will be converted to a dict using cgi.parse_qs. 
    25      
    26     If you omit 'params', the params from the original request will 
    27     remain in effect, including any POST parameters. 
    28     """ 
    29      
    30     def __init__(self, path, params=None): 
     21    If you supply a query string, it will be replace request.params. 
     22    If you omit the query string, the params from the original request will 
     23    remain in effect. 
     24    """ 
     25     
     26    def __init__(self, path): 
    3127        import cherrypy 
    3228        request = cherrypy.request 
     29         
     30        if "?" in path: 
     31            # Pop any params included in the path 
     32            path, pm = path.split("?", 1) 
     33            request.query_string = pm 
     34            request.params = httptools.parseQueryString(pm) 
    3335         
    3436        # Note that urljoin will "do the right thing" whether url is: 
     
    4244        self.path = path 
    4345         
    44         if params is not None: 
    45             if isinstance(params, basestring): 
    46                 request.query_string = params 
    47                 pm = cgi.parse_qs(params, keep_blank_values=True) 
    48                 for key, val in pm.items(): 
    49                     if len(val) == 1: 
    50                         pm[key] = val[0] 
    51                 request.params = pm 
    52             else: 
    53                 request.query_string = urllib.urlencode(params) 
    54                 request.params = params.copy() 
    55          
    56         Exception.__init__(self, path, params) 
     46        Exception.__init__(self, path) 
    5747 
    5848 
  • trunk/cherrypy/_cprequest.py

    r1118 r1130  
    9292        When run() is done, the returned object should have 3 attributes: 
    9393          status, e.g. "200 OK" 
    94           headers, a list of (name, value) tuples 
     94          header_list, a list of (name, value) tuples 
    9595          body, an iterable yielding strings 
    9696         
  • trunk/cherrypy/test/test_core.py

    r1128 r1130  
    154154            if user_id == "parrot": 
    155155                # Trade it for a slug when redirecting 
    156                 raise cherrypy.InternalRedirect('/image/getImagesByUser', 
    157                                                "user_id=slug") 
     156                raise cherrypy.InternalRedirect('/image/getImagesByUser?user_id=slug') 
    158157            elif user_id == "terrier": 
    159158                # Trade it for a fish when redirecting 
    160                 raise cherrypy.InternalRedirect('/image/getImagesByUser', 
    161                                                {"user_id": "fish"}
     159                cherrypy.request.params = {"user_id": "fish"} 
     160                raise cherrypy.InternalRedirect('/image/getImagesByUser'
    162161            else: 
    163162                raise cherrypy.InternalRedirect('/image/getImagesByUser') 

Hosted by WebFaction

Log in as guest/cpguest to create tickets