@classmethod<EOL><INDENT>def create_index(cls, app, wh):<DEDENT>
<EOL>if app.extensions['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>storage = RamStorage()<EOL>index = storage.create_index(wh.schema)<EOL>assert index<EOL>return index<EOL><DEDENT>else:<EOL><INDENT>index_path = os.path.join(app.extensions['<STR_LIT>']['<STR_LIT>'],<EOL>getattr(wh, '<STR_LIT>', cls.camel_to_snake(wh.__name__)))<EOL>if whoosh.index.exists_in(index_path):<EOL><INDENT>index = whoosh.index.open_dir(index_path)<EOL><DEDENT>else:<EOL><INDENT>if not os.path.exists(index_path):<EOL><INDENT>os.makedirs(index_path)<EOL><DEDENT>index = whoosh.index.create_in(index_path, wh.schema)<EOL><DEDENT>return index<EOL><DEDENT>
Creates and opens an index for the given whoosheer and app.
        If the index already exists, it just opens it, otherwise it creates
        it first.

        :param app: The application instance.
        :param wh: The whoosheer instance for which a index should be created.