Add support for decorating MethodViews with @Blueprint.route()#3405
Add support for decorating MethodViews with @Blueprint.route()#3405dougthor42 wants to merge 6 commits intopallets:masterfrom
Conversation
|
You can already use Also, this should probably apply to |
|
Going to close this due to lack of response. I'm open to merging this in the future, but it needs improvement. |
|
Sorry for the delay.
I've added a blurb for this to the docs. Let me know if you're happy with it. I also added a second example for Blueprints+MethodViews.
Can you elaborate on this? My naive interpretation is just: diff --git a/src/flask/blueprints.py b/src/flask/blueprints.py
index 0e974ab2..13392174 100644
--- a/src/flask/blueprints.py
+++ b/src/flask/blueprints.py
@@ -14,6 +14,7 @@ from functools import update_wrapper
from .helpers import _endpoint_from_view_func
from .helpers import _PackageBoundObject
from .views import MethodViewType
+from .views import View
# a singleton sentinel value for parameter defaults
_sentinel = object()
@@ -283,7 +284,7 @@ class Blueprint(_PackageBoundObject):
endpoint = options.pop("endpoint", f.__name__)
# Support decorating MethodView classes. See Issue #3404
- if isinstance(f, MethodViewType):
+ if isinstance(f, (View, MethodViewType)):
f = f.as_view(endpoint)
self.add_url_rule(rule, endpoint, f, **options)Is that what you're talking about or am I completely misunderstanding? |
|
Oh, and you can see the changes in https://github.com/dougthor42/flask/tree/blueprints-and-methodviews. I thought that GH would continue to update the MR even after it's closed, but I thought wrong. |
This updates the
Blueprint.routedecorator to support decoratingMethodViewclasses.Fixes Issue #3404.
Comments
versionchangedand the changelog entry. If this is incorrect please let me know.blueprints.pybut really only effectviews, so I put it inview.py.