maarten-dp / flask-restless-datamodel

Server side code for flask-restless-client
MIT License
1 stars 4 forks source link

Version 0.2.10 introduced a bug when used with Flask-Admin #7

Closed JesseDeLoore closed 2 years ago

JesseDeLoore commented 2 years ago

After trying to run our tests with the new version, we found that we are unable to build the Flask application. Because the name of the blueprint is passed explicitly we see the following error (instead of the usual warning): image

I suspect there is a naming conflict with Flask-admin that already registered the role blueprint. From what I can tell this is caused by:

datamodel.py:135 self.app.register_blueprint(blueprint, name=collection_name)
datamodel.py:113 collection_name = api_info.collection_name
datamodel.py:55 api_info = data_model.api_manager.created_apis_for[model]
flask_restless/manager.py:646 self.created_apis_for[model] = APIInfo(collection_name, blueprint.name)
flask_restless/manager.py:550-551 
 if collection_name is None:
            collection_name = model.__tablename__ # this get's set to 'role' 

We can circumvent the issue by explicitly setting a collection_name with a prefix/suffix on api creation. But I'm not sure that it really solves the issue.

maarten-dp commented 2 years ago

I'll try to have a look this evening.

maarten-dp commented 2 years ago

Actually, it's a 2 min fix... I pushed something, could you try installing the master branch and running your tests again? pip install git+https://github.com/maarten-dp/flask-restless-datamodel.git

If this works I'll do a release this evening, if not, let me know what the issue is and I'll continue this evening.

JesseDeLoore commented 2 years ago

That seems to work! Thanks a lot.

maarten-dp commented 2 years ago

0.2.11 is released :)