Skip to content

Although I installed the Flask-Whoshee package as described in the document, I am getting the following error during the query process. #68

Description

@Ildemselcuk

@xsuchy @evilkost @pjcunningham @bkabrda @wassname

İnstall procces

main.py

import os
import tempfile
from flask_login.login_manager import LoginManager
from werkzeug import debug
from app import db
from flask_bootstrap import Bootstrap
from flask_marshmallow import Marshmallow
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from werkzeug.debug import DebuggedApplication
from flask import Flask
from flask_datepicker import datepicker
from flask_mail import Mail
from flask_allows import Allows
from app.model import User
from flask_cors import CORS
from flask_wtf.csrf import CSRFProtect
from flask_whooshee import Whooshee

basedir = os.path.abspath(os.path.dirname(__file__))
whooshee = Whooshee()
db = SQLAlchemy()
ma = Marshmallow()
migrate = Migrate()
mail = Mail()
login_manager = LoginManager()
allows = Allows()
cors = CORS()
csrf = CSRFProtect()

def create_app():

    app = Flask(__name__)
    app.secret_key = 's3cr3t'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_ECHO'] = True
    app.config['SQLALCHEMY_POOL_SIZE'] = 1
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://foo:bardb1@db:3306/foo'
    app.config['UPLOADED_IMAGES_DEST'] = 'uploads/images'
    app.config['MAIL_SERVER'] = 'localhost'
    app.config['MAIL_PORT'] = 25
    app.config['MAIL_USE_TLS'] = False
    app.config['MAIL_USE_SSL'] = False
    app.config['WHOOSHEE_DIR'] = tempfile.mkdtemp()
    app.config.update(
        UPLOADED_PATH=os.path.join(basedir, 'uploads'),
    )
    app.config.from_mapping({'WTF_CSRF_ENABLED': True})

    from app.task_manager.route import task_manager_bp
    from app.auth.route import auth_bp

    Bootstrap(app)
    datepicker(app)
    db.init_app(app)
    ma.init_app(app)
    csrf.init_app(app)

    cors.init_app(app)
    migrate.init_app(app, db)
    mail.init_app(app)
    login_manager.init_app(app)
    allows.init_app(app)
    whooshee.init_app(app)
    login_manager.login_view = "auth.login"
    # User loader callback

    @login_manager.user_loader
    def load_user(user_id):
        return User.query.get(int(user_id))

    from flask_login import current_user

    allows.identity_loader(lambda: current_user)

    app.register_blueprint(task_manager_bp)
    app.register_blueprint(auth_bp)

    if app.debug:
        app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)

    return app

if __name__ == "__main__":
    app = create_app()
    app.run(debug=True)

model.py

from app import whooshee

@whooshee.register_model('column1')
class Foo(db.Model):
    __tablename__ = 'foo'
    id = db.Column(db.Integer, primary_key=True)
    column1 = db.Column('task_id', db.Integer, db.ForeignKey('task.id'))
    column2 = db.Column('field_name', db.String(64))

route.py

from app.model import Foo

@task_manager_bp.route("/searchable", methods=['GET', 'POST'])
def isSearchable():

    results = Foo.query.whooshee_search('Test').all()
    return jsonify({"success":True,"body":results},200)
### Error
127.0.0.1 - - [05/Feb/2022 21:45:32] "GET /searchable HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/app/task_manager/route.py", line 92, in isSearchable
    results = TaskHistory.query.whooshee_search('Te').all()
  File "/Users/selcukIldem/Documents/Flask-Projects/ad-task-management/venv/lib/python3.9/site-packages/flask_whooshee-0.8.2-py3.9.egg/flask_whooshee.py", line 96, in whooshee_search
    whoosheer = next(w for w in _get_config(self)['whoosheers']
StopIteration
127.0.0.1 - - [05/Feb/2022 21:45:33] "GET /searchable?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -

OS Software : MacOS Monterey
Python Version : Python 3.9.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions