Skip to content
Myr

Moved wsgi_app down to a more logical location

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent c360f00 · Browse files · 1 file+41 added−41 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+41 added−41 removed

  • other:+41 added−41 removed

1 file+41 added−41 removed

modified:flask/app.py+41 added-41 removed
764 unmodified lines
765 for handler in funcs:766 response = handler(response)767 return response768769 def wsgi_app(self, environ, start_response):770 """The actual WSGI application. This is not implemented in771 `__call__` so that middlewares can be applied without losing a772 reference to the class. So instead of doing this::773774 app = MyMiddleware(app)775776 It's a better idea to do this instead::777778 app.wsgi_app = MyMiddleware(app.wsgi_app)779780 Then you still have the original application object around and781 can continue to call methods on it.782783 .. versionchanged:: 0.4784 The :meth:`after_request` functions are now called even if an785 error handler took over request processing. This ensures that786 even if an exception happens database have the chance to787 properly close the connection.788789 :param environ: a WSGI environment790 :param start_response: a callable accepting a status code,791 a list of headers and an optional792 exception context to start the response793 """794 with self.request_context(environ):795 try:796 request_started.send(self)797 rv = self.preprocess_request()798 if rv is None:799 rv = self.dispatch_request()800 response = self.make_response(rv)801 except Exception, e:802 response = self.make_response(self.handle_exception(e))803 try:804 response = self.process_response(response)805 except Exception, e:806 response = self.make_response(self.handle_exception(e))807 request_finished.send(self, response=response)808 return response(environ, start_response)809769 def request_context(self, environ):770 """Creates a request context from the given environment and binds771 it to the current context. This must be used in combination with772 the `with` statement because the request is only bound to the
39 unmodified lines
812 """813 from werkzeug import create_environ814 return self.request_context(create_environ(*args, **kwargs))815816 def wsgi_app(self, environ, start_response):817 """The actual WSGI application. This is not implemented in818 `__call__` so that middlewares can be applied without losing a819 reference to the class. So instead of doing this::820821 app = MyMiddleware(app)822823 It's a better idea to do this instead::824825 app.wsgi_app = MyMiddleware(app.wsgi_app)826827 Then you still have the original application object around and828 can continue to call methods on it.829830 .. versionchanged:: 0.4831 The :meth:`after_request` functions are now called even if an832 error handler took over request processing. This ensures that833 even if an exception happens database have the chance to834 properly close the connection.835836 :param environ: a WSGI environment837 :param start_response: a callable accepting a status code,838 a list of headers and an optional839 exception context to start the response840 """841 with self.request_context(environ):842 try:843 request_started.send(self)844 rv = self.preprocess_request()845 if rv is None:846 rv = self.dispatch_request()847 response = self.make_response(rv)848 except Exception, e:849 response = self.make_response(self.handle_exception(e))850 try:851 response = self.process_response(response)852 except Exception, e:853 response = self.make_response(self.handle_exception(e))854 request_finished.send(self, response=response)855 return response(environ, start_response)856857 def __call__(self, environ, start_response):858 """Shortcut for :attr:`wsgi_app`."""859 return self.wsgi_app(environ, start_response)