The bottle WSGI-interface.
(self, environ, start_response)
| 812 | % type(first)), request, response) |
| 813 | |
| 814 | def wsgi(self, environ, start_response): |
| 815 | """ The bottle WSGI-interface. """ |
| 816 | try: |
| 817 | environ['bottle.app'] = self |
| 818 | request.bind(environ) |
| 819 | response.bind() |
| 820 | out = self._cast(self._handle(environ), request, response) |
| 821 | # rfc2616 section 4.3 |
| 822 | if response._status_code in (100, 101, 204, 304)\ |
| 823 | or request.method == 'HEAD': |
| 824 | if hasattr(out, 'close'): out.close() |
| 825 | out = [] |
| 826 | start_response(response._status_line, list(response.iter_headers())) |
| 827 | return out |
| 828 | except (KeyboardInterrupt, SystemExit, MemoryError): |
| 829 | raise |
| 830 | except Exception, e: |
| 831 | if not self.catchall: raise |
| 832 | err = '<h1>Critical error while processing request: %s</h1>' \ |
| 833 | % environ.get('PATH_INFO', '/') |
| 834 | if DEBUG: |
| 835 | err += '<h2>Error:</h2>\n<pre>%s</pre>\n' % repr(e) |
| 836 | err += '<h2>Traceback:</h2>\n<pre>%s</pre>\n' % format_exc(10) |
| 837 | environ['wsgi.errors'].write(err) #TODO: wsgi.error should not get html |
| 838 | start_response('500 INTERNAL SERVER ERROR', [('Content-Type', 'text/html')]) |
| 839 | return [tob(err)] |
| 840 | |
| 841 | def __call__(self, environ, start_response): |
| 842 | ''' Each instance of :class:'Bottle' is a WSGI application. ''' |
no test coverage detected