forked from orbit-oss/flask
Flask no longer internally depends on rules being added through the add_url_rule function
This commit is contained in:
parent
07688d7b93
commit
99be2ec022
3 changed files with 23 additions and 1 deletions
3
CHANGES
3
CHANGES
|
|
@ -27,6 +27,9 @@ Release date to be announced, codename to be selected
|
||||||
used to flip the setting of exception propagation which previously
|
used to flip the setting of exception propagation which previously
|
||||||
was linked to `DEBUG` alone and is now linked to either `DEBUG` or
|
was linked to `DEBUG` alone and is now linked to either `DEBUG` or
|
||||||
`TESTING`.
|
`TESTING`.
|
||||||
|
- Flask no longer internally depends on rules being added through the
|
||||||
|
`add_url_rule` function and can now also accept regular werkzeug
|
||||||
|
rules added to the url map.
|
||||||
|
|
||||||
Version 0.6.1
|
Version 0.6.1
|
||||||
-------------
|
-------------
|
||||||
|
|
|
||||||
|
|
@ -730,7 +730,8 @@ class Flask(_PackageBoundObject):
|
||||||
rule = req.url_rule
|
rule = req.url_rule
|
||||||
# if we provide automatic options for this URL and the
|
# if we provide automatic options for this URL and the
|
||||||
# request came with the OPTIONS method, reply automatically
|
# request came with the OPTIONS method, reply automatically
|
||||||
if rule.provide_automatic_options and req.method == 'OPTIONS':
|
if getattr(rule, 'provide_automatic_options', False) \
|
||||||
|
and req.method == 'OPTIONS':
|
||||||
return self.make_default_options_response()
|
return self.make_default_options_response()
|
||||||
# otherwise dispatch to the handler for that endpoint
|
# otherwise dispatch to the handler for that endpoint
|
||||||
return self.view_functions[rule.endpoint](**req.view_args)
|
return self.view_functions[rule.endpoint](**req.view_args)
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,24 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert rv.status_code == 405
|
assert rv.status_code == 405
|
||||||
assert sorted(rv.allow) == ['GET', 'HEAD', 'OPTIONS', 'POST']
|
assert sorted(rv.allow) == ['GET', 'HEAD', 'OPTIONS', 'POST']
|
||||||
|
|
||||||
|
def test_werkzeug_routing(self):
|
||||||
|
from werkzeug.routing import Submount, Rule
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
app.url_map.add(Submount('/foo', [
|
||||||
|
Rule('/bar', endpoint='bar'),
|
||||||
|
Rule('/', endpoint='index')
|
||||||
|
]))
|
||||||
|
def bar():
|
||||||
|
return 'bar'
|
||||||
|
def index():
|
||||||
|
return 'index'
|
||||||
|
app.view_functions['bar'] = bar
|
||||||
|
app.view_functions['index'] = index
|
||||||
|
|
||||||
|
c = app.test_client()
|
||||||
|
assert c.get('/foo/').data == 'index'
|
||||||
|
assert c.get('/foo/bar').data == 'bar'
|
||||||
|
|
||||||
def test_session(self):
|
def test_session(self):
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
app.secret_key = 'testkey'
|
app.secret_key = 'testkey'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue