Permalink
Browse files

Worked around a werkzeug bug with redirects

  • Loading branch information...
1 parent c26a6dd commit a101cfc35be437ad0e4f56da0d92f14c27abda67 @mitsuhiko mitsuhiko committed Jun 29, 2011
Showing with 22 additions and 0 deletions.
  1. +1 −0 CHANGES
  2. +6 −0 flask/app.py
  3. +15 −0 tests/flask_tests.py
View
@@ -9,6 +9,7 @@ Version 0.7.1
Bugfix release, release date to be decided.
- Added missing future import that broke 2.5 compatibility.
+- Fixed an infinite redirect issue with blueprints.
Version 0.7
-----------
View
@@ -706,6 +706,12 @@ def index():
if 'OPTIONS' not in methods:
methods = tuple(methods) + ('OPTIONS',)
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.provide_automatic_options = provide_automatic_options
self.url_map.add(rule)
View
@@ -1364,6 +1364,21 @@ def backend_index():
self.assertEqual(c.get('/fe2').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):

0 comments on commit a101cfc

Please sign in to comment.