greyli / helloflask

Hello, Flask!
https://docs.helloflask.com
MIT License
1.87k stars 2.53k forks source link

Albumy 探索 报错 AttributeError: 'WhoosheeQuery' object has no attribute '_join_entities' #241

Closed Slian22 closed 8 months ago

Slian22 commented 3 years ago

当我点击搜索按钮的时候,显示错误 Traceback (most recent call last): File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 2309, in call return self.wsgi_app(environ, start_response) File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask_compat.py", line 35, in reraise raise value File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask_compat.py", line 35, in reraise raise value File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "D:\GraDesign\MyGraduationProject\GraduationProject-CS\Code\albumy\albumy\blueprints\main.py", line 59, in search pagination = Photo.query.whooshee_search(q).paginate(page, per_page) File "C:\Users\Slian.virtualenvs\albumy-ABVUmZFk\Lib\site-packages\flask_whooshee.py", line 66, in whooshee_search if self._join_entities and isinstance(self._join_entities[0], Mapper): AttributeError: 'WhoosheeQuery' object has no attribute '_join_entities' 我已经把版本降到对应的版本了。为何还是出错? whoosh = "==2.7.4" flask-whooshee = "==0.6.0" flask = "==1.0.2" flask-dropzone = "==1.5" image

Slian22 commented 3 years ago

请教一下,蹲一个答复。

greyli commented 3 years ago

这个报错是因为 SQLAlchemy 1.4 带来了一些破坏性变动。建议尝试使用示例程序固定的 SQLAlchemy 版本:

pip install sqlalchemy==1.3.15

等后续这个问题修复了再更新。

Slian22 commented 3 years ago

目前我尝试一种解决方案并且可行。修改flask_whooshee.py文件,并在里面注释掉这部分。

if self._join_entities and isinstance(self._join_entities[0], Mapper):
    # SQLAlchemy >= 0.8.0
    entities.update(set([x.entity for x in self._join_entities]))
else:
    # SQLAlchemy < 0.8.0
    entities.update(set(self._join_entities))
greyli commented 3 years ago

降低 SQLAlchemy 版本到 1.3.15 没用吗?

Slian22 commented 3 years ago

这个我没试过,但是上述方法可取

greyli commented 8 months ago

这个问题已在 Flask-Whooshee 新版本修复。