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

Changeset 1158

Show
Ignore:
Timestamp:
06/25/06 17:45:06
Author:
fumanchu
Message:

Added bare_error trap in _cpmodpy (which fixes some failing tests). Also dropped redundant cookie logic in _cpmodpy.

Files:

Legend:

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

    r1156 r1158  
    33from mod_python import apache 
    44import cherrypy 
     5from cherrypy._cperror import format_exc, bare_error 
    56 
    67 
     
    8788        response = request.run(requestLine, headers, rfile) 
    8889         
    89         sendResponse(req, response
     90        sendResponse(req, response.status, response.header_list, response.body
    9091        request.close() 
    9192    except: 
    92         cherrypy.log(traceback=True) 
     93        tb = format_exc() 
     94        cherrypy.log(tb) 
     95        s, h, b = bare_error() 
     96        sendResponse(req, s, h, b) 
    9397    return apache.OK 
    9498 
    95 def sendResponse(req, response): 
     99def sendResponse(req, status, headers, body): 
    96100    # Set response status 
    97     req.status = int(response.status[:3]) 
     101    req.status = int(status[:3]) 
    98102     
    99103    # Set response headers 
    100104    req.content_type = "text/plain" 
    101     for header, value in response.header_list
     105    for header, value in headers
    102106        if header.lower() == 'content-type': 
    103107            req.content_type = value 
     
    105109        req.headers_out.add(header, value) 
    106110     
    107     # Cookie 
    108     cook_out = response.simple_cookie.output() 
    109     if cook_out: 
    110         for line in cook_out.split('\n'): 
    111             req.headers_out.add(*tuple(v.strip() for v in line.split(':', 1))) 
    112      
    113111    # Set response body 
    114     if isinstance(response.body, basestring): 
    115         req.write(response.body) 
     112    if isinstance(body, basestring): 
     113        req.write(body) 
    116114    else: 
    117         for seg in response.body: 
     115        for seg in body: 
    118116            req.write(seg) 
     117 

Hosted by WebFaction

Log in as guest/cpguest to create tickets