python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.16k stars 335 forks source link

'BlueprintSetupState' object has no attribute 'subdomain' #97

Open pansila opened 4 years ago

pansila commented 4 years ago

Code

from quart import Blueprint, Quart
from flask_restplus import Api

blueprint = Blueprint('api', __name__)
api = Api(blueprint)
app = Quart(__name__)
app.register_blueprint(blueprint)

Repro Steps (if applicable)

  1. start the app

Expected Behavior

App starts successfully

Actual Behavior

An exception occurs

Error Messages/Stack Trace

Traceback (most recent call last):
  File "manage.py", line 20, in <module>
    app.register_blueprint(blueprint)
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\quart\app.py", line 1422, in register_blueprint
    blueprint.register(self, first_registration, url_prefix=url_prefix)
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\quart\blueprints.py", line 755, in register
    func(state)
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\flask_restx\api.py", line 840, in _deferred_blueprint_init
    self._init_app(setup_state.app)
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\flask_restx\api.py", line 228, in _init_app
    self._register_specs(self.blueprint or app)
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\flask_restx\api.py", line 285, in _register_specs
    resource_class_args=(self,),
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\flask_restx\api.py", line 349, in _register_view
    url, view_func=resource_func, **kwargs
  File "C:\Users\username\AppData\Local\pypoetry\Cache\virtualenvs\auto-test-system-4gCsnwKR-py3.7\lib\site-packages\flask_restx\api.py", line 803, in _blueprint_setup_add_url_rule_patch
    options.setdefault("subdomain", blueprint_setup.subdomain)
AttributeError: 'BlueprintSetupState' object has no attribute 'subdomain'

Environment

Additional Context

I know it's due to the different implementations between Flask and Quart, espacially add_url_rule in this case, and I understand Quart is not flask-restx's target. But by any chance to bring this excellent extenstion to Quart would be great and should be easy. Thansk a lot.

engFelipeMonteiro commented 3 years ago

The root of the problem is that quart.blueprint.register parameters differ from flask.blueprint.register, the others errors is workaroundable.

pgjones commented 3 years ago

This should be fixed in Quart 0.15 onwards.

billsioros commented 2 years ago

Hello everyone 👋🏽 Is flask-restx compatible with quart in the first place?