Index: quixote/publish.py =================================================================== RCS file: /home/cvs/quixote/publish.py,v retrieving revision 1.135 diff -c -r1.135 publish.py *** quixote/publish.py 3 Oct 2002 14:35:52 -0000 1.135 --- quixote/publish.py 7 Oct 2002 01:59:22 -0000 *************** *** 209,215 **** def parse_request (self, request): """Parse the request information waiting in 'request'. """ ! self.start_time = time.time() request.process_inputs() def start_request (self, request): --- 209,215 ---- def parse_request (self, request): """Parse the request information waiting in 'request'. """ ! request.start_time = time.time() request.process_inputs() def start_request (self, request): *************** *** 218,223 **** --- 218,237 ---- """ pass + def set_request(self, request): + """Called by process_request to set the current connection's request + object.""" + self._request = request + + def get_request(self): + """Called by quixote.get_request() to get the request object.""" + return self._request + + def clear_request(self): + """Called at the end of each try_publish() call. + Invalidates the publisher's pointer to the current request object. + """ + def log_request (self, request): """Log a request in the access_log file. """ *************** *** 227,233 **** else: user = "-" now = time.time() ! seconds = now - self.start_time now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) --- 241,247 ---- else: user = "-" now = time.time() ! seconds = now - request.start_time now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) *************** *** 620,629 **** try_publish() method will be called to do the work and exceptions will be handled here. """ ! global _request ! _request = request ! output = self.try_publish(request, env.get('PATH_INFO', '')) self.log_request(request) if output and self.config.compress_pages: --- 634,646 ---- try_publish() method will be called to do the work and exceptions will be handled here. """ ! self.set_request(request) ! try: ! output = self.try_publish(request, env.get('PATH_INFO', '')) ! finally: ! self.clear_request() ! self.log_request(request) if output and self.config.compress_pages: *************** *** 736,775 **** # Publisher singleton, only one of these per process. _publisher = None - # The request currently being processed. - _request = None - - # N.B. _publisher and _request should be accessed by functions only. This - # allows multithreaded implementations to use per thread tables for these - # objects. - def get_publisher(): global _publisher return _publisher def get_request(): ! global _request ! return _request def get_path(n=0): ! global _request ! return _request.get_path(n) def redirect(location, permanent=0): ! global _request ! return _request.redirect(location, permanent) def get_session(): ! global _request ! return _request.session def get_session_manager (): global _publisher return _publisher.session_mgr def get_user(): ! global _request ! session = _request.session if session is None: return None else: --- 753,785 ---- # Publisher singleton, only one of these per process. _publisher = None def get_publisher(): global _publisher return _publisher def get_request(): ! global _publisher ! return _publisher.get_request() def get_path(n=0): ! global _publisher ! return _publisher.get_request().get_path(n) def redirect(location, permanent=0): ! global _publisher ! return _publisher.get_request().redirect(location, permanent) def get_session(): ! global _publisher ! return _publisher.get_request().session def get_session_manager (): global _publisher return _publisher.session_mgr def get_user(): ! global _publisher ! session = _publisher.get_request().session if session is None: return None else: