File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -1305,17 +1305,18 @@ def make_default_options_response(self):
1305
1305
1306
1306
.. versionadded:: 0.7
1307
1307
"""
1308
- # This would be nicer in Werkzeug 0.7, which however currently
1309
- # is not released. Werkzeug 0.7 provides a method called
1310
- # allowed_methods() that returns all methods that are valid for
1311
- # a given path.
1312
- methods = []
1313
- try :
1314
- _request_ctx_stack .top .url_adapter .match (method = '--' )
1315
- except MethodNotAllowed , e :
1316
- methods = e .valid_methods
1317
- except HTTPException , e :
1318
- pass
1308
+ adapter = _request_ctx_stack .top .url_adapter
1309
+ if hasattr (adapter , 'allowed_methods' ):
1310
+ methods = adapter .allowed_methods ()
1311
+ else :
1312
+ # fallback for Werkzeug < 0.7
1313
+ methods = []
1314
+ try :
1315
+ adapter .match (method = '--' )
1316
+ except MethodNotAllowed , e :
1317
+ methods = e .valid_methods
1318
+ except HTTPException , e :
1319
+ pass
1319
1320
rv = self .response_class ()
1320
1321
rv .allow .update (methods )
1321
1322
return rv
You can’t perform that action at this time.
0 commit comments