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

Changeset 1496

Show
Ignore:
Timestamp:
12/09/06 16:59:31
Author:
fumanchu
Message:

2.x Fix for #507 (InternalRedirect?? supports only absolute paths). Paths relative to request.path are now possible by omitting the leading slash from the path.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/_cperror.py

    r1482 r1496  
    22 
    33import urllib 
     4import urlparse 
     5 
    46 
    57class Error(Exception): 
     
    3335        import cgi 
    3436        request = cherrypy.request 
     37         
     38        # Note that urljoin will "do the right thing" whether url is: 
     39        #  1. a URL relative to root (e.g. "/dummy") 
     40        #  2. a URL relative to the current path 
     41        # Note that any querystring will be discarded. 
     42        path = urlparse.urljoin(cherrypy.request.path, path) 
    3543         
    3644        # Set a 'path' member attribute so that code which traps this 
     
    6674     
    6775    def __init__(self, urls, status=None): 
    68         import urlparse 
    6976        import cherrypy 
    7077         
  • branches/cherrypy-2.x/cherrypy/test/test_core.py

    r1489 r1496  
    141141        def index(self): 
    142142            raise cherrypy.InternalRedirect("/") 
     143         
     144        def relative(self): 
     145            raise cherrypy.InternalRedirect("cousin") 
     146         
     147        def cousin(self): 
     148            return "I am a redirected page." 
    143149         
    144150        def petshop(self, user_id): 
     
    573579        self.assertBody('Please log in') 
    574580        self.assertStatus(200) 
     581        self.assertStatus(200) 
     582         
     583        # Relative path in InternalRedirect 
     584        self.getPage("/internalredirect/relative") 
     585        self.assertBody('I am a redirected page.') 
    575586         
    576587        # HTTPRedirect on error 

Hosted by WebFaction

Log in as guest/cpguest to create tickets