Ejemplo n.º 1
0
    def get_new_jndi_connection(self):
        """
        Returns a zxJDBC Connection object obtained from a JNDI data source if
        the settings dictionary contains the JNDI_NAME entry on the
        DATABASE_OPTIONS dictionary, or None if it doesn't.
        :return: zxJDBC Connection
        """
        settings_dict = dict(self.settings_dict)

        if 'OPTIONS' not in settings_dict:
            return None
        if 'JNDI_NAME' not in settings_dict['OPTIONS']:
            return None

        name = settings_dict['OPTIONS']['JNDI_NAME']
        props = settings_dict['OPTIONS'].get('JNDI_CONTEXT_OPTIONS', {})

        return zxJDBC.lookup(name, keywords=props)
Ejemplo n.º 2
0
    def new_jndi_connection(self):
        """
        Returns a zxJDBC Connection object obtained from a JNDI data source if
        the settings dictionary contains the JNDI_NAME entry on the
        DATABASE_OPTIONS dictionary, or None if it doesn't.
        """
        settings_dict = self.settings_dict
        if 'DATABASE_OPTIONS' not in settings_dict:
            return None
        if 'JNDI_NAME' not in settings_dict['DATABASE_OPTIONS']:
            return None

        name = settings_dict['DATABASE_OPTIONS']['JNDI_NAME']
        props = settings_dict['DATABASE_OPTIONS'].get('JNDI_CONTEXT_OPTIONS', {})
        # Default the JNDI endpoint to a Glassfish instance
        # running on localhost
        #     jndi_endpoint = settings_dict['DATABASE_OPTIONS'].get('JNDI_ENDPOINT', 'localhost:3700')
        #     jndi_ctx_factory = settings_dict['DATABASE_OPTIONS'].get('JNDI_INITIAL_CONTEXT_FACTORY', 'localhost:3700')
        #     props = {'com.sun.appserv.iiop.endpoints':jndi_endpoint,
        #              Context.INITIAL_CONTEXT_FACTORY:jndi_ctx_factory}
        return zxJDBC.lookup(name, keywords=props)