Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodView methods not inherited #3138

Closed
aparamon opened this issue Apr 3, 2019 · 1 comment · Fixed by #3179
Closed

MethodView methods not inherited #3138

aparamon opened this issue Apr 3, 2019 · 1 comment · Fixed by #3179
Milestone

Comments

@aparamon
Copy link

aparamon commented Apr 3, 2019

To reproduce:

import flask
import flask.views

class BaseView(flask.views.MethodView):
    methods = ['GET', 'PROPFIND']

class MyView(BaseView):
    def get(self):
        return None, 200
    def propfind(self):
        return None, 200

app = flask.Flask(__name__)
app.add_url_rule('/test', view_func=MyView.as_view('test'))

for rule in app.url_map.iter_rules():
    print(rule, ','.join(rule.methods))

Expected Behavior

/test OPTIONS,PROPFIND,GET,HEAD
/static/<path:filename> OPTIONS,GET,HEAD

Actual Behavior

/test OPTIONS,GET,HEAD
/static/<path:filename> OPTIONS,GET,HEAD

Environment

  • Python version: 3.7.1
  • Flask version: Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
  • Werkzeug version: 0.15.2
@aparamon
Copy link
Author

aparamon commented Apr 3, 2019

One possible solution/workaround would be to enable extending flask.views.http_method_funcs globally. MethodViewType.__init__ is smart enough to filter http_method_funcs by actually present class methods. Currently flask.views.http_method_funcs is a frozenset which proves limiting.

@davidism davidism added this to the 1.1.0 milestone May 17, 2019
davidism added a commit that referenced this issue May 17, 2019
jab added a commit to jab/flask that referenced this issue May 23, 2019
…TRIBUTING

Now that we have a Black pre-commit hook (pallets#3138),
ensure pre-commit gets installed on ``pip install -e .[dev]``
and document use of Black (rather than "try to follow pep8")
in CONTRIBUTING.
jab added a commit to jab/flask that referenced this issue May 23, 2019
…TRIBUTING

Now that we have a Black pre-commit hook (pallets#3138),
ensure pre-commit gets installed on ``pip install -e .[dev]``
and document use of Black (rather than "try to follow pep8")
in CONTRIBUTING.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants