Ejemplo n.º 1
0
    def setUp(self):
        dbname = self._config['couchdb.db'].dbname

        # Set the directory to the fixtures.
        try:
            self._config['couchdb.db'].server.delete_db(dbname)
        except ResourceNotFound:
            pass

        self._config['couchdb.db'] = init_db(self._config['couchdb.uri'], dbname)
        sync_design(self._config['couchdb.db'], default_design_path(self._config))

        if hasattr(self, 'fixtures'):
            fixtures_dir = self._config['couchdb.fixtures']
            if not os.path.isdir(fixtures_dir):
                raise Exception("Fixtures dir %s not found" % fixtures_dir)
            FixtureLoader(fixtures_dir).sync(self._config['couchdb.db'])
Ejemplo n.º 2
0
    def command(self):
        """Main command to sync db"""
        config_file = self.args[0]

        config_name = "config:%s" % config_file
        here_dir = os.getcwd()

        if not self.options.quiet:
            # Configure logging from the config file
            self.logging_file_config(config_file)

        # Load the wsgi app first so that everything is initialized right
        wsgiapp = loadapp(config_name, relative_to=here_dir)
        try:
            design_path = wsgiapp.config["couchdb.design"]
        except KeyError:
            design_path = default_design_path(wsgiapp.config)

        # This syncs the main database.
        sync_design(wsgiapp.config["couchdb.db"], design_path)