Closed riklaunim closed 7 years ago
Yeah, it could be probably achieved by using "extras_require" - https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
Yes, you're right, this project will be more flexible thanks to that. I'm looking for the recommended way to make conditional import of the my data layer mongo module. I also have to implement a clean warning if you want to use the mongo data layer without extra requirements. If you allready know the best way to do this, please give me a link, it will be faster to me to include this feature.
I have recently implemented the feature to manage relationship with rest according to this specification: http://jsonapi.org/format/#fetching-relationships and http://jsonapi.org/format/#crud-updating-relationships so i will release a new version on pypi with those new feature next week or in the beginning of next year.
Thanks
I see MongoDataLayer in two init files so if like it wasn't imported anywhere then it would work - someone importing MongoDataLayer in their code would get the import exception if not having mongodb (or you can try/except/raise custom exception on the import in the data layer file - AFAIK that's what Django does with some things like PIL/Pillow for ImageField)
ok thx i will follow your advice
New release is available on pypi
This is still an issue if you import SqlalchemyDataLayer.
from flask_rest_jsonapi import Api, ResourceList, SqlalchemyDataLayer
File "/builds/0deb0f6d/0/.tox/py35/lib/python3.5/site-packages/flask_rest_jsonapi/__init__.py", line 5, in <module>
from flask_rest_jsonapi.data_layers import SqlalchemyDataLayer
File "/builds/0deb0f6d/0/.tox/py35/lib/python3.5/site-packages/flask_rest_jsonapi/data_layers/__init__.py", line 4, in <module>
from flask_rest_jsonapi.data_layers.mongo import MongoDataLayer
File "/builds/0deb0f6d/0/.tox/py35/lib/python3.5/site-packages/flask_rest_jsonapi/data_layers/mongo.py", line 6, in <module>
from pymongo import ASCENDING, DESCENDING
ImportError: No module named 'pymongo'
SqlalchemyDataLayer calls the data_layers/init.py module, which has the pymongo requirement from the mongo.MongoDataLayer file.
I've made PR to fix what @philof mentioned: #9
Installing flask-rest-jsonapi will also install pymongo even if I don't use MongoDB. The problem is that pymongo conflicts with other bson implementations which hit me in one project.
Is pymongo a must have for flask-rest-jsonapi to work (without using mongo)?