Merge branch '0.10-maintenance'
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 · parents c938771, 141a553 · Browse files · 3 files·+26 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+26 added−2 removed
- other:+26 added−2 removed
Provenance
- Commit
a950358- Tree
a21fef0- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
c938771- Parent 2
141a553
3 files changed+26 added−2 removed
modified:flask/testsuite/basic.py+22 added-1 removed
13 unmodified lines14 import flask15 import pickle16 import unittest17 from datetime import datetime18-from threading import Thread18+from threading import Thread, Condition19 from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning20 from flask._compat import text_type21 from werkzeug.exceptions import BadRequest, NotFound22 from werkzeug.http import parse_date1071 unmodified lines1094 c.get('/')1095 self.assert_equal(got, [42])1096 self.assert_true(app.got_first_request)1097 1098+ def test_before_first_request_functions_concurrent(self):1099+ got = []1100+ app = flask.Flask(__name__)1101+ cv = Condition()1102+ @app.before_first_request1103+ def foo():1104+ with cv:1105+ cv.wait()1106+ got.append(42)1107+ c = app.test_client()1108+ def get_and_assert():1109+ with cv:1110+ cv.notify()1111+ c.get("/")1112+ self.assert_equal(got, [42])1113+ t = Thread(target=get_and_assert)1114+ t.start()1115+ get_and_assert()1116+ t.join()1117+ self.assert_true(app.got_first_request)1118+1119 def test_routing_redirect_debugging(self):1120 app = flask.Flask(__name__)1121 app.debug = True1122 @app.route('/foo/', methods=['GET', 'POST'])233 unmodified linesmodified:flask/app.py+1 added-1 removed
1489 unmodified lines1490 return1491 with self._before_request_lock:1492 if self._got_first_request:1493 return1494- self._got_first_request = True1494 for func in self.before_first_request_funcs:1495 func()1496+ self._got_first_request = True1497 1498 def make_default_options_response(self):1499 """This method is called to create the default `OPTIONS` response.1500 This can be changed through subclassing to change the default346 unmodified linesmodified:CHANGES+3 added
33 unmodified lines34 - Made `@before_first_request` into a decorator as intended.35 - Fixed an etags bug when sending a file streams with a name.36 - Fixed `send_from_directory` not expanding to the application root path37 correctly.38+- Changed logic of before first request handlers to flip the flag after39+ invoking. This will allow some uses that are potentially dangerous but40+ should probably be permitted.41 42 Version 0.10.143 --------------44 457 unmodified lines