Browse Source

Worked around a werkzeug bug with redirects

pull/269/head
Armin Ronacher 14 years ago
parent
commit
a101cfc35b
  1. 1
      CHANGES
  2. 6
      flask/app.py
  3. 15
      tests/flask_tests.py

1
CHANGES

@ -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
-----------

6
flask/app.py

@ -706,6 +706,12 @@ class Flask(_PackageBoundObject):
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)

15
tests/flask_tests.py

@ -1364,6 +1364,21 @@ class BlueprintTestCase(unittest.TestCase):
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):

Loading…
Cancel
Save