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

NameError: File '_MAIN_0.toc' exists #62

Closed
RoseOu opened this issue Aug 18, 2017 · 0 comments
Closed

NameError: File '_MAIN_0.toc' exists #62

RoseOu opened this issue Aug 18, 2017 · 0 comments
Labels

Comments

@RoseOu
Copy link

RoseOu commented Aug 18, 2017

Hello, I install Flask-WhooshAlchemy and config according to your QuickStart,
but when I use docker to deploy my app, run it and visit my route,it raise the error:

File "/usr/local/lib/python2.7/site-packages/whoosh/filedb/filestore.py", line 552, in rename_file
  raise NameError("File %r exists" % newname)
NameError: File '_MAIN_0.toc' exists

My code:

app/Init.py:

import flask_whooshalchemy as whooshalchemy

def create_app(config_name=None, main=True):
    if config_name is None:
        config_name = 'default'
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    config[config_name].init_app(app)
    db.init_app(app)
    moment.init_app(app)
    toolbar.init_app(app)
    login_manager.init_app(app)

    from .models import BlogPost
    whooshalchemy.whoosh_index(app, BlogPost)

    return app

app = create_app(config_name = 'default')

app/models.py:

class BlogPost(db.Model):
    __tablename__ = 'blogpost'
    __searchable__ = ['title', 'content'] 

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)  
    content = app.db.Column(db.Text)  

config.py

class Config:
    WHOOSH_BASE = os.path.join(basedir,"whoosh_index")
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

2 participants