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

Changeset 624

Show
Ignore:
Timestamp:
09/11/05 01:05:56
Author:
fumanchu
Message:

Fix for #208; HTTPRedirect can now be raised in error handlers.

Files:

Legend:

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

    r623 r624  
    428428         
    429429        applyFilters('afterErrorResponse') 
     430        return 
     431    except cherrypy.HTTPRedirect, inst: 
     432        try: 
     433            inst.set_response() 
     434            finalize() 
     435            return 
     436        except: 
     437            # Fall through to the second error handler 
     438            pass 
    430439    except: 
    431         # Failure in _cpOnError, error filter, or finalize. 
    432         # Bypass them all. 
    433         defaultOn = (cherrypy.config.get('server.environment') == 'development') 
    434         if cherrypy.config.get('server.showTracebacks', defaultOn): 
    435             body = dbltrace % (_cputil.formatExc(exc), _cputil.formatExc()) 
    436         else: 
    437             body = "" 
    438         response = cherrypy.response 
    439         response.status, response.headers, response.body = bareError(body) 
    440  
     440        # Fall through to the second error handler 
     441        pass 
     442     
     443    # Failure in _cpOnError, error filter, or finalize. 
     444    # Bypass them all. 
     445    defaultOn = (cherrypy.config.get('server.environment') == 'development') 
     446    if cherrypy.config.get('server.showTracebacks', defaultOn): 
     447        body = dbltrace % (_cputil.formatExc(exc), _cputil.formatExc()) 
     448    else: 
     449        body = "" 
     450    response = cherrypy.response 
     451    response.status, response.headers, response.body = bareError(body) 
    441452 
    442453def bareError(extrabody=None): 
  • trunk/cherrypy/test/test_core.py

    r619 r624  
    100100 
    101101class Redirect(Test): 
     102     
     103    def _cpOnError(self): 
     104        raise cherrypy.HTTPRedirect("/errpage") 
     105     
     106    def error(self): 
     107        raise NameError() 
    102108     
    103109    def index(self): 
     
    462468        self.assertBody('0 images for fish') 
    463469        self.assertStatus('200 OK') 
     470         
     471        # HTTPRedirect on error 
     472        self.getPage("/redirect/error") 
     473        self.assertStatus('303 See Other') 
     474        self.assertInBody('/errpage') 
    464475     
    465476    def testFlatten(self): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets