Logo Search packages:      
Sourcecode: zope-mysqlda version File versions  Download package

def zope-mysqlda-3.0~beta1::db::DBPool::__call__ (   self,
  connection 
)

Parse the connection string.

    Initiate a trial connection with the database to check
    transactionality once instead of once per DB instance.

    Create database if option is enabled and database doesn't exist.

Definition at line 191 of file db.py.

00191                                   :
        """ Parse the connection string.

            Initiate a trial connection with the database to check
            transactionality once instead of once per DB instance.

            Create database if option is enabled and database doesn't exist.
        """
        self.connection = connection
        DB = self.DB
        #
        db_flags = DB._parse_connection_string(connection, self.use_unicode)
        self._db_flags = db_flags

        # connect to server to determin tranasactional capabilities
        # can't use DB instance as it requires this information to work
        try:
            connection = MySQLdb.connect(**db_flags['kw_args'])
        except OperationalError:
            if self._create_db:
                kw_args = db_flags.get('kw_args',{}).copy()
                db = kw_args.pop('db',None)
                if not db: raise
                connection = MySQLdb.connect(**kw_args)
                create_query = "create database %s" % db
                if self.use_unicode:
                    create_query += (" default character set %s"
                            % DB.unicode_charset)
                connection.query(create_query)
                connection.store_result()
            else:
                raise
        transactional = connection.server_capabilities & CLIENT.TRANSACTIONS
        connection.close()

        # Some tweaks to transaction/locking db_flags based on server setup
        if db_flags['try_transactions'] == '-':
            transactional = False
        elif not transactional and db_flags['try_transactions'] == '+':
            raise NotSupportedError, "transactions not supported by this server"
        db_flags['transactions'] = transactional
        del db_flags['try_transactions']
        if transactional or db_flags['mysql_lock']:
            db_flags['use_TM'] = True

        # will not be 100% accurate in regard to per thread connections
        # but as close as we're going to get it.
        self.connected_timestamp = DateTime()

        # return self as the database connection object 
        # (assigned to _v_database_connection)
        return self

    def closeConnection(self):


Generated by  Doxygen 1.6.0   Back to index