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

Changeset 904

Show
Ignore:
Timestamp:
12/30/05 20:09:29
Author:
fumanchu
Message:

Made custom Request subclasses easier to implement:

  1. Moved some required code from Request._run to Request.run, so overriding _run doesn't have to repeat it.
  2. The _cpserver.Server class now has a request_class attribute, which is used to instantiate the class returned by server.request. It defaults to _cphttptools.Request.
Files:

Legend:

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

    r892 r904  
    6161        self.rfile = rfile 
    6262         
     63        self.headers = httptools.HeaderMap() 
     64        self.headerMap = self.headers # Backward compatibility 
     65        self.simpleCookie = Cookie.SimpleCookie() 
     66         
    6367        if cherrypy.profiler: 
    6468            cherrypy.profiler.run(self._run) 
    6569        else: 
    6670            self._run() 
     71         
     72        if self.method == "HEAD": 
     73            # HEAD requests MUST NOT return a message-body in the response. 
     74            cherrypy.response.body = [] 
     75         
     76        _cputil.get_special_attribute("_cp_log_access", "_cpLogAccess")() 
     77         
    6778        return cherrypy.response 
    6879     
     
    7081         
    7182        try: 
    72             self.headers = httptools.HeaderMap() 
    73             self.headerMap = self.headers # Backward compatibility 
    74             self.simpleCookie = Cookie.SimpleCookie() 
    75              
    7683            # This has to be done very early in the request process, 
    7784            # because request.object_path is used for config lookups 
     
    118125                raise 
    119126            cherrypy.response.handleError(sys.exc_info()) 
    120          
    121         if self.method == "HEAD": 
    122             # HEAD requests MUST NOT return a message-body in the response. 
    123             cherrypy.response.body = [] 
    124          
    125         _cputil.get_special_attribute("_cp_log_access", "_cpLogAccess")() 
    126127     
    127128    def processRequestLine(self): 
  • trunk/cherrypy/_cpserver.py

    r897 r904  
    2222 
    2323class Server(object): 
     24     
     25    request_class = _cphttptools.Request 
    2426     
    2527    def __init__(self): 
     
    200202                func(i) 
    201203         
    202         r = _cphttptools.Request(clientAddress[0], clientAddress[1], 
    203                                  remoteHost, scheme) 
     204        r = self.request_class(clientAddress[0], clientAddress[1], 
     205                              remoteHost, scheme) 
    204206        cherrypy.serving.request = r 
    205207        cherrypy.serving.response = _cphttptools.Response() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets