'Defers loading until needed.'

def setup(self):

    from haystack import connections
    new_index = False
    if (self.use_file_storage and (not os.path.exists(self.path))):
        os.makedirs(self.path)
        new_index = True
    if (self.use_file_storage and (not os.access(self.path, os.W_OK))):
        raise IOError((u"The    path    to    your    Whoosh    index    '%s'    is    not    writable    for    the    current    user/group." % self.path))
    if self.use_file_storage:
        self.storage = FileStorage(self.path)
    else:
        global LOCALS
        if (getattr(LOCALS, u'RAM_STORE', None) is None):
            LOCALS.RAM_STORE = RamStorage()
        self.storage = LOCALS.RAM_STORE
    (self.content_field_name, self.schema) = self.build_schema(connections[self.connection_alias].get_unified_index().all_searchfields())
    self.parser = QueryParser(self.content_field_name, schema=self.schema)
    if (new_index is True):
        self.index = self.storage.create_index(self.schema)
    else:
        try:
            self.index = self.storage.open_index(schema=self.schema)
        except index.EmptyIndexError:
            self.index = self.storage.create_index(self.schema)
    self.setup_complete = True
