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

Comments

@aparamon
Copy link

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

This comment has been minimized.

Copy link
Author

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

Merge pull request #3179 from Lee-W/MethodView-inheritance
Fix MethodView inheritance Error (#3138)

jab added a commit to jab/flask that referenced this issue May 23, 2019

Add pre-commit to dev dependencies, document it and pre-commit in CON…
…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

Add pre-commit to dev dependencies, document it and pre-commit in CON…
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.