Django

Code

Changeset 3876

Show
Ignore:
Timestamp:
09/27/06 21:07:00 (2 years ago)
Author:
adrian
Message:

Folded django.core.handlers.modpython.populate_apache_request into ModPythonHandler?.call() to save the overhead of a function call, and because that logic didn't need to be abstracted.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/handlers/modpython.py

    r3875 r3876  
    161161 
    162162        # Convert our custom HttpResponse object back into the mod_python req. 
    163         populate_apache_request(response, req) 
     163        req.content_type = response['Content-Type'] 
     164        for key, value in response.headers.items(): 
     165            if key != 'Content-Type': 
     166                req.headers_out[key] = value 
     167        for c in response.cookies.values(): 
     168            req.headers_out.add('Set-Cookie', c.output(header='')) 
     169        req.status = response.status_code 
     170        try: 
     171            for chunk in response: 
     172                req.write(chunk) 
     173        finally: 
     174            response.close() 
     175 
    164176        return 0 # mod_python.apache.OK 
    165  
    166 def populate_apache_request(http_response, mod_python_req): 
    167     "Populates the mod_python request object with an HttpResponse" 
    168     mod_python_req.content_type = http_response['Content-Type'] 
    169     for key, value in http_response.headers.items(): 
    170         if key != 'Content-Type': 
    171             mod_python_req.headers_out[key] = value 
    172     for c in http_response.cookies.values(): 
    173         mod_python_req.headers_out.add('Set-Cookie', c.output(header='')) 
    174     mod_python_req.status = http_response.status_code 
    175     try: 
    176         for chunk in http_response: 
    177             mod_python_req.write(chunk) 
    178     finally: 
    179         http_response.close() 
    180177 
    181178def handler(req):