Mercurial > p > roundup > code
comparison roundup/cgi/wsgi_handler.py @ 3990:0728808fdf5c
make WSGI threadsafe
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 18 Aug 2008 05:09:00 +0000 |
| parents | a2d22d0de0bc |
| children | 859ab007829f |
comparison
equal
deleted
inserted
replaced
| 3989:0112e9e1d068 | 3990:0728808fdf5c |
|---|---|
| 35 self.translator = None | 35 self.translator = None |
| 36 | 36 |
| 37 def __call__(self, environ, start_response): | 37 def __call__(self, environ, start_response): |
| 38 """Initialize with `apache.Request` object""" | 38 """Initialize with `apache.Request` object""" |
| 39 self.environ = environ | 39 self.environ = environ |
| 40 self.__start_response = start_response | 40 request = RequestDispatcher(self.home, self.debug, self.timing) |
| 41 request.__start_response = start_response | |
| 41 | 42 |
| 42 self.wfile = Writer(self) | 43 request.wfile = Writer(request) |
| 43 self.__wfile = None | 44 request.__wfile = None |
| 44 | 45 |
| 45 tracker = roundup.instance.open(self.home, not self.debug) | 46 tracker = roundup.instance.open(self.home, not self.debug) |
| 46 | 47 |
| 47 # need to strip the leading '/' | 48 # need to strip the leading '/' |
| 48 environ["PATH_INFO"] = environ["PATH_INFO"][1:] | 49 environ["PATH_INFO"] = environ["PATH_INFO"][1:] |
| 49 if self.timing: | 50 if request.timing: |
| 50 environ["CGI_SHOW_TIMING"] = self.timing | 51 environ["CGI_SHOW_TIMING"] = request.timing |
| 51 | 52 |
| 52 form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) | 53 form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) |
| 53 | 54 |
| 54 client = tracker.Client(tracker, self, environ, form, | 55 client = tracker.Client(tracker, request, environ, form, |
| 55 self.translator) | 56 request.translator) |
| 56 try: | 57 try: |
| 57 client.main() | 58 client.main() |
| 58 except roundup.cgi.client.NotFound: | 59 except roundup.cgi.client.NotFound: |
| 59 self.start_response([('Content-Type', 'text/html')], 404) | 60 request.start_response([('Content-Type', 'text/html')], 404) |
| 60 self.wfile.write('Not found: %s'%client.path) | 61 request.wfile.write('Not found: %s'%client.path) |
| 61 | 62 |
| 62 # all body data has been written using wfile | 63 # all body data has been written using wfile |
| 63 return [] | 64 return [] |
| 64 | 65 |
| 65 def start_response(self, headers, response_code): | 66 def start_response(self, headers, response_code): |
