You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using flask's own MethodView with flask injector, the app fails with the error:
Traceback (most recent call last):
File "/Users/jacksontoomey1/.virtualenvs/rooster-d4LzYqiE/lib/python3.7/site-packages/flask_injector.py", line 101, in wrap_class_based_view
class_kwargs = fun_closure['class_kwargs']
KeyError: 'class_kwargs'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "example.py", line 28, in <module>
FlaskInjector(app=app, modules=[])
File "/Users/jacksontoomey1/.virtualenvs/rooster-d4LzYqiE/lib/python3.7/site-packages/flask_injector.py", line 317, in __init__
process_dict(container, injector)
File "/Users/jacksontoomey1/.virtualenvs/rooster-d4LzYqiE/lib/python3.7/site-packages/flask_injector.py", line 344, in process_dict
d[key] = wrap_fun(value, injector)
File "/Users/jacksontoomey1/.virtualenvs/rooster-d4LzYqiE/lib/python3.7/site-packages/flask_injector.py", line 81, in wrap_fun
return wrap_class_based_view(fun, injector)
File "/Users/jacksontoomey1/.virtualenvs/rooster-d4LzYqiE/lib/python3.7/site-packages/flask_injector.py", line 104, in wrap_class_based_view
flask_restful_api = fun_closure['self']
KeyError: 'self'
Here is an example that fails.
from functools import wraps
from flask import Flask
from flask.views import MethodView
from flask_injector import FlaskInjector
app = Flask(__name__)
def my_wrapper(f):
@wraps(f)
def _wrapper(*args, **kwargs):
return f(*args, **kwargs)
return _wrapper
class MyView(MethodView):
decorators = [my_wrapper]
def get(self):
return 'Hello'
app.add_url_rule('/', view_func=MyView.as_view('index'))
FlaskInjector(app=app, modules=[])
if __name__ == '__main__':
app.run()
The text was updated successfully, but these errors were encountered:
I meant to have a look at this some time ago but I forgot and I don't have time now. Pull requests that fix this (if it's even possible) are welcome though.
When using flask's own MethodView with flask injector, the app fails with the error:
Here is an example that fails.
The text was updated successfully, but these errors were encountered: