Browse Source

make_default_options_response now tries to use Werkzeug 0.7 functionality before falling back.

pull/309/head
Armin Ronacher 14 years ago
parent
commit
b256e9f36c
  1. 11
      flask/app.py

11
flask/app.py

@ -1305,13 +1305,14 @@ class Flask(_PackageBoundObject):
.. versionadded:: 0.7 .. versionadded:: 0.7
""" """
# This would be nicer in Werkzeug 0.7, which however currently adapter = _request_ctx_stack.top.url_adapter
# is not released. Werkzeug 0.7 provides a method called if hasattr(adapter, 'allowed_methods'):
# allowed_methods() that returns all methods that are valid for methods = adapter.allowed_methods()
# a given path. else:
# fallback for Werkzeug < 0.7
methods = [] methods = []
try: try:
_request_ctx_stack.top.url_adapter.match(method='--') adapter.match(method='--')
except MethodNotAllowed, e: except MethodNotAllowed, e:
methods = e.valid_methods methods = e.valid_methods
except HTTPException, e: except HTTPException, e:

Loading…
Cancel
Save