def run(self):

        db.drop_all()
        # Setup the database
        db.create_all()
        # Rollback any lingering transactions
        db.session.rollback()

        # Construct a list of paths within which fixtures may reside
        default_fixtures_dir = os.path.join(current_app.root_path, 'fixtures')
        # All relative paths should be relative to the app's root directory.
        fixtures_dirs = [default_fixtures_dir]

        # Load all of the fixtures
        for filename in config.FIXTURES_LIST.split(","):
            for directory in fixtures_dirs:
                filepath = os.path.join(directory, filename)
                if not os.path.exists(filepath):
                    continue

                load_fixtures(db, loaders.load(filepath))
                break

            else:
                raise IOError(
                    "Error loading '{0}'. File could not be found".format(
                        filename))
Exemplo n.º 2
0
 def load_fixtures(self, file_name):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     for document in Document.all():
         index_document(document)
     self.update_index()
Exemplo n.º 3
0
    def test_custom_loader_is_used_first(self):
        add(CustomJSONLoader)
        path = os.path.join(app.root_path, "fixtures", "authors.json")
        data = load(path)
        remove(CustomJSONLoader)

        assert ["foo"] == data
Exemplo n.º 4
0
 def load_fixtures(self, file_name):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     update_collections()
     for doc in Document.all():
         process_document(doc)
     self.flush_index()
Exemplo n.º 5
0
Arquivo: util.py Projeto: tomjie/aleph
 def load_fixtures(self, file_name, process_documents=True):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     reindex_entities()
     if process_documents:
         for doc in Document.all():
             analyze_document(doc)
         optimize_search()
Exemplo n.º 6
0
 def load_fixtures(self, file_name, process_documents=True):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     reindex_entities()
     if process_documents:
         for doc in Document.all():
             analyze_document(doc)
         optimize_search()
Exemplo n.º 7
0
 def load_fixtures(self, file_name, process_documents=True):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     reindex_entities()
     if process_documents:
         for doc in Document.all():
             process_document(doc)
     self.flush_index()
Exemplo n.º 8
0
 def load_fixtures(self, file_name):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     self.update_index()
Exemplo n.º 9
0
def _load_fixtures(app, db):
    for fixture in app.config.get('STARTUP_FIXTURES', []):
        load_fixtures(
            db, loaders.load(os.path.join(app.root_path, 'fixtures', fixture)))
Exemplo n.º 10
0
Arquivo: util.py Projeto: pudo/aleph
 def load_fixtures(self, file_name):
     filepath = self.get_fixture_path(file_name)
     load_fixtures(db, loaders.load(filepath))
     db.session.commit()
     self.update_index()