mirror of https://github.com/pallets/flask.git
Worked around a werkzeug bug with redirects
This commit is contained in:
parent
c26a6dd50c
commit
a101cfc35b
1
CHANGES
1
CHANGES
|
@ -9,6 +9,7 @@ Version 0.7.1
|
||||||
Bugfix release, release date to be decided.
|
Bugfix release, release date to be decided.
|
||||||
|
|
||||||
- Added missing future import that broke 2.5 compatibility.
|
- Added missing future import that broke 2.5 compatibility.
|
||||||
|
- Fixed an infinite redirect issue with blueprints.
|
||||||
|
|
||||||
Version 0.7
|
Version 0.7
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -706,6 +706,12 @@ class Flask(_PackageBoundObject):
|
||||||
if 'OPTIONS' not in methods:
|
if 'OPTIONS' not in methods:
|
||||||
methods = tuple(methods) + ('OPTIONS',)
|
methods = tuple(methods) + ('OPTIONS',)
|
||||||
provide_automatic_options = True
|
provide_automatic_options = True
|
||||||
|
|
||||||
|
# due to a werkzeug bug we need to make sure that the defaults are
|
||||||
|
# None if they are an empty dictionary. This should not be necessary
|
||||||
|
# with Werkzeug 0.7
|
||||||
|
options['defaults'] = options.get('defaults') or None
|
||||||
|
|
||||||
rule = self.url_rule_class(rule, methods=methods, **options)
|
rule = self.url_rule_class(rule, methods=methods, **options)
|
||||||
rule.provide_automatic_options = provide_automatic_options
|
rule.provide_automatic_options = provide_automatic_options
|
||||||
self.url_map.add(rule)
|
self.url_map.add(rule)
|
||||||
|
|
|
@ -1364,6 +1364,21 @@ class BlueprintTestCase(unittest.TestCase):
|
||||||
self.assertEqual(c.get('/fe2').data.strip(), '/fe')
|
self.assertEqual(c.get('/fe2').data.strip(), '/fe')
|
||||||
self.assertEqual(c.get('/be').data.strip(), '/fe')
|
self.assertEqual(c.get('/be').data.strip(), '/fe')
|
||||||
|
|
||||||
|
def test_empty_url_defaults(self):
|
||||||
|
bp = flask.Blueprint('bp', __name__)
|
||||||
|
|
||||||
|
@bp.route('/', defaults={'page': 1})
|
||||||
|
@bp.route('/page/<int:page>')
|
||||||
|
def something(page):
|
||||||
|
return str(page)
|
||||||
|
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
app.register_blueprint(bp)
|
||||||
|
|
||||||
|
c = app.test_client()
|
||||||
|
self.assertEqual(c.get('/').data, '1')
|
||||||
|
self.assertEqual(c.get('/page/2').data, '2')
|
||||||
|
|
||||||
|
|
||||||
class SendfileTestCase(unittest.TestCase):
|
class SendfileTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue