Skip to content
Myr

Better reraising of exceptions

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 b51ecd7 · Browse files · 3 files+37 added−2 removed
This commit

State

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

Diff stats

3 files+37 added−2 removed

  • other:+37 added−2 removed

3 files+37 added−2 removed

modified:docs/config.rst+2 added-1 removed
238 unmodified lines
239 even create your own script for sourcing that activates a virtualenv240 and exports the development configuration for you.241- Use a tool like `fabric`_ in production to push code and242 configurations separately to the production server(s). For some243 details about how to do that, head over to the :ref:`deploy` pattern.243 details about how to do that, head over to the244 :ref:`fabric-deployment` pattern.245246.. _fabric: http://fabfile.org/
modified:docs/extensiondev.rst+23 added
288 unmodified lines
289and bind their app to the extension in another file::290291 manager.init_app(app)292293End-Of-Request Behavior294-----------------------295296Due to the change in Flask 0.7 regarding functions that are run at the end297of the request your extension will have to be extra careful there if it298wants to continue to support older versions of Flask. The following299pattern is a good way to support both::300301 def close_connection(response):302 ctx = _request_ctx_stack.top303 ctx.sqlite3_db.close()304 return response305306 if hasattr(app, 'teardown_request'):307 app.teardown_request(close_connection)308 else:309 app.after_request(close_connection)310311Strictly speaking the above code is wrong, because teardown functions are312passed the exception and typically don't return anything. However because313the return value is discarded this will just work assuming that the code314in between does not touch the passed parameter.315316Learn from Others317-----------------318319This documentation only touches the bare minimum for extension
64 unmodified lines
modified:flask/app.py+12 added-1 removed
791 unmodified lines
792 exists, a default 500 internal server error message is displayed.793794 .. versionadded: 0.3795 """796 exc_type, exc_value, tb = sys.exc_info()797798 got_request_exception.send(self, exception=e)799 handler = self.error_handlers.get(500)800801 if self.propagate_exceptions:802 # if we want to repropagate the exception, we can attempt to803 # raise it with the whole traceback in case we can do that804 # (the function was actually called from the except part)805 # otherwise, we just raise the error again806 if exc_value is e:807 raise exc_type, exc_value, tb808 else:799 raise809 raise e810811 self.logger.exception('Exception on %s [%s]' % (812 request.path,813 request.method814 ))
253 unmodified lines