예제 #1
0
 def handleError(self, exc):
     """Set status, headers, and body when an unanticipated error occurs."""
     try:
         applyFilters('before_error_response')
        
         # _cp_on_error will probably change self.body.
         # It may also change the headers, etc.
         _cputil.get_special_attribute('_cp_on_error', '_cpOnError')()
         
         self.finalize()
         
         applyFilters('after_error_response')
         return
     except cherrypy.HTTPRedirect, inst:
         try:
             inst.set_response()
             self.finalize()
             return
         except (KeyboardInterrupt, SystemExit):
             raise
         except:
             # Fall through to the second error handler
             pass
예제 #2
0
 def _run(self):
     
     try:
         # This has to be done very early in the request process,
         # because request.object_path is used for config lookups
         # right away.
         self.processRequestLine()
         
         try:
             applyFilters('on_start_resource', failsafe=True)
             
             try:
                 self.processHeaders()
                 
                 applyFilters('before_request_body')
                 if self.processRequestBody:
                     self.processBody()
                 
                 # Loop to allow for InternalRedirect.
                 while True:
                     try:
                         applyFilters('before_main')
                         if self.execute_main:
                             self.main()
                         break
                     except cherrypy.InternalRedirect, ir:
                         self.object_path = ir.path
                 
                 applyFilters('before_finalize')
                 cherrypy.response.finalize()
             except cherrypy.RequestHandled:
                 pass
             except (cherrypy.HTTPRedirect, cherrypy.HTTPError), inst:
                 # For an HTTPRedirect or HTTPError (including NotFound),
                 # we don't go through the regular mechanism:
                 # we return the redirect or error page immediately
                 inst.set_response()
                 applyFilters('before_finalize')
                 cherrypy.response.finalize()
         finally:
             applyFilters('on_end_resource', failsafe=True)
예제 #3
0
 def close(self):
     if not self.closed:
         self.closed = True
         applyFilters('on_end_request', failsafe=True)
         cherrypy.serving.__dict__.clear()