コード例 #1
0
ファイル: db_io.py プロジェクト: gtaylor/dott
    def prepare_and_load(self):
        """
        Gets a connection set up.
        """

        # Instantiate the connection to Postgres.
        self._db = txPGDictConnection()
        conn_info = get_db_connection_kwargs(db_mode=self._db_mode)
        yield self._db.connect(**conn_info)
コード例 #2
0
ファイル: db_io.py プロジェクト: jordangumm-progenity/dott
    def prepare_and_load(self):
        """
        Gets a connection set up.
        """

        # Instantiate the connection to Postgres.
        self._db = txPGDictConnection()
        conn_info = get_db_connection_kwargs(db_mode=self._db_mode)
        yield self._db.connect(**conn_info)
コード例 #3
0
    def create_clean_game_env(self):
        """
        Creates a fresh set of stores, DBs, and etc.
        """

        global DB_WAS_CREATED
        if not DB_WAS_CREATED:
            # We have to use psycopg2 directly since txpostgres can't
            # be used with autocommit=True.
            conn_info = get_db_connection_kwargs(db_mode='test', include_db=False)
            conn = psycopg2.connect(**conn_info)
            conn.set_session(autocommit=True)
            cur = conn.cursor()
            # Destroy and re-create the test DB to make sure the
            # schema is current.
            cur.execute("DROP DATABASE IF EXISTS %s;" % settings.TEST_DATABASE['database'])
            cur.execute("CREATE DATABASE %s WITH OWNER=%s;" % (
                settings.TEST_DATABASE['database'], conn_info['user']
            ))
            cur.close()
            conn.close()

            conn_info = get_db_connection_kwargs(db_mode='test')
            conn = psycopg2.connect(**conn_info)
            conn.set_session(autocommit=True)
            cur = conn.cursor()
            # Load the schema from the export.
            schema_file = os.path.join(settings.BASE_PATH, 'misc', 'dott-schema.sql')
            schema = open(schema_file).read()
            cur.execute(schema)
            cur.close()
            conn.close()
            DB_WAS_CREATED = True

        self.mud_service = MockMudService()
        yield self.mud_service.prep_and_load()
        self.global_cmd_table = self.mud_service.global_cmd_table
        self.command_handler = self.mud_service.command_handler
        self.session_manager = self.mud_service.session_manager
        self.object_store = self.mud_service.object_store
        self.account_store = self.mud_service.account_store
コード例 #4
0
ファイル: db_io.py プロジェクト: jordangumm-progenity/dott
    def prepare_and_load(self):
        """
        Prepares the store for duty, then loads all objects from the DB into
        the object store.
        """

        # Just in case this is a code reload.
        self.store._accounts = {}
        # Instantiate the connection to Postgres.
        self._db = txPGDictConnection()
        conn_info = get_db_connection_kwargs(db_mode=self._db_mode)
        yield self._db.connect(**conn_info)
コード例 #5
0
ファイル: db_io.py プロジェクト: gtaylor/dott
    def prepare_and_load(self):
        """
        Prepares the store for duty, then loads all objects from the DB into
        the object store.
        """

        # Just in case this is a code reload.
        self.store._accounts = {}
        # Instantiate the connection to Postgres.
        self._db = txPGDictConnection()
        conn_info = get_db_connection_kwargs(db_mode=self._db_mode)
        yield self._db.connect(**conn_info)