support classes in addition to functions for views
This commit is contained in:
parent
1e4e578d73
commit
42b756411a
2 changed files with 6 additions and 4 deletions
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 3d964b660442e23faedf801caed6e3c7bd42d5c9
|
||||
|
|
@ -507,8 +507,8 @@ class Flask(_PackageBoundObject):
|
|||
:param endpoint: the endpoint for the registered URL rule. Flask
|
||||
itself assumes the name of the view function as
|
||||
endpoint
|
||||
:param view_func: the function to call when serving a request to the
|
||||
provided endpoint
|
||||
:param view_func: the function, or class, to call when serving a request to the
|
||||
provided endpoint.
|
||||
:param options: the options to be forwarded to the underlying
|
||||
:class:`~werkzeug.routing.Rule` object. A change
|
||||
to Werkzeug is handling of method options. methods
|
||||
|
|
@ -708,7 +708,10 @@ class Flask(_PackageBoundObject):
|
|||
if rule.provide_automatic_options and req.method == 'OPTIONS':
|
||||
return self.make_default_options_response()
|
||||
# otherwise dispatch to the handler for that endpoint
|
||||
return self.view_functions[rule.endpoint](**req.view_args)
|
||||
view_function = self.view_functions[rule.endpoint]
|
||||
if isinstance(view_function, type):
|
||||
view_function = view_function()
|
||||
return view_function(**req.view_args)
|
||||
except HTTPException, e:
|
||||
return self.handle_http_exception(e)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue