コード例 #1
0
    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))
コード例 #2
0
ファイル: util.py プロジェクト: mustafaascha/aleph
 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()
コード例 #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
コード例 #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()
コード例 #5
0
ファイル: util.py プロジェクト: 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()
コード例 #6
0
ファイル: util.py プロジェクト: CodeForAfrica/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()
コード例 #7
0
ファイル: util.py プロジェクト: kkrbalam/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():
             process_document(doc)
     self.flush_index()
コード例 #8
0
ファイル: util.py プロジェクト: vishalbelsare/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()
コード例 #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)))
コード例 #10
0
ファイル: util.py プロジェクト: 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()