Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whoosh_index function runs _create_index on every call ignoring cache. #58

Closed
arabidopsis opened this issue Nov 13, 2016 · 3 comments
Closed
Labels

Comments

@arabidopsis
Copy link

although the comment in whoosh index say that "gets the whoosh index for this model, creating one if it does not exist." the code - lines (168-169)

return app.whoosh_indexes.get(model.__name__,
                _create_index(app, model))

belies this comment.

@jrast
Copy link
Contributor

jrast commented Nov 13, 2016

Why do you think so? _create_index adds the newly created index to app.whoosh_indexes.

See https://github.com/gyllstromk/Flask-WhooshAlchemy/blob/master/flask_whooshalchemy.py#L209

@arabidopsis
Copy link
Author

I was expecting something like:

if model.__name__ in app.whoosh_indexes:
      return app.whoosh_indexes[model.__name__]
else:
      return _create_index(app, model)

i.e. _create_index is only called if the model is not in the app whoosh cache.

currently _create_index is called whether or not the model is in the app cache 'whoosh_indexes'
-- since python is strict in its arguments i.e._create_index(app,model) is called before app.whoosh_indexes.get is ever called. No? Or is this what you want... I might have the wrong
end of the stick.

BTW whoosh looks like an awesome package.

@jrast
Copy link
Contributor

jrast commented Nov 15, 2016

Oh, that's correct!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants