comet.datapool

The comet.datapool module provides global connection access for the current session and facilities to establish the global comet data connection.

Methods

comet.datapool.getConnection() None | CSOAP | CSQL | str

Get the current global data connection if it is established.

Returns:

The active data connection

The type is dependant of the connection itself:

Return type:

None | CSOAP | CSQL | str

Available:

InDesign® comet_pdf® Illustrator®

CScript:
Examples:

Get the current data connection and log information based on the type of connection.

#!py
#pragma plain

import comet

def main():
    connection = comet.datapool.getConnection()

    if not connection:
        comet.wlog('Not connected')
    else:
        comet.wlog('Connection:')

        if isinstance(connection, str):
            #XML Pool
            comet.wlog(
                f'\t Type: XML'
                f'\n\t Path: {connection}'
            )
        elif isinstance(connection, comet.CSOAP):
            #SOAP
            comet.wlog(
                f'\t Type: SOAP'
                f'\n\t Server: {connection.getServer()}'
                f'\n\t User: {connection.getUser()}'
                f'\n\t Language: {connection.getLanguage()}'
                f'\n\t Client: {connection.getClient()}'
            )
        elif isinstance(connection, comet.CSQL):
            #SQL
            comet.wlog(
                f'\t Type: CSQL'
                f'\n\t Server: {connection.getServer()}'
                f'\n\t User: {connection.getUser()}'
                f'\n\t DB Name: {connection.getDBName()}'
                f'\n\t Client: {connection.getClient()}'
                f'\n\t Charset: {connection.getCharset()}'
            )

    return 0
comet.datapool.getSessionID() str

Get the session ID of the current publishing server connection.

Returns:

The session ID if available, else empty str.

Return type:

str

Available:

InDesign® comet_pdf® Illustrator®

CScript:

system::session_id

comet.datapool.loginSOAP(host: str, user: str = '', password: str = '', language: str = '', client: str = '', lazy: bool = True) CSOAP

Establish the global data connection by connecting to a SOAP service, e.g. a publishing server.

Parameters:
  • host (str) – Service name

  • user (str) – Username

  • password (str) – Password

  • language (str) – Language

  • client (str) – Client

  • lazy (bool) – Only login when the connection is different than the current one?

Returns:

The new connection

Return type:

CSOAP

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

datapool::login

Examples:

Log into a local publishing server.

comet.datapool.loginSOAP('http://localhost:40080/CometBridge/Comet3Service', 'admin', 'admin', client = 'demoID')
comet.datapool.loginDB(host, user: str = '', password: str = '', database: str = '', client: str = '', lazy: bool = True) CSQL

Establish the global data connection by connecting to an SQL database.

Parameters:
  • host (str) – Service name

  • user (str) – Username

  • password (str) – Password

  • database (str) – Database name

  • client (str) – Client

  • lazy (bool) – Only login when the connection is different than the current one?

Returns:

The new connection

Return type:

CSQL

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

datapool::login

Examples:

Log into a local database.

comet.datapool.loginDB('localhost:3306', 'root', 'root', 'comet_config')
comet.datapool.loginXML(path: str) None

Establish the global data connection by connecting to a local XML pool.

Parameters:

path (str) – The path to the local XML pool

Return type:

None

Raises:
Available:

InDesign® comet_pdf® Illustrator®

CScript:

datapool::login

Examples:

Log into an XML pool on the desktop.

comet.datapool.loginXML(comet.uncurtain('$DESKTOP/DemoPool'))
comet.datapool.logout() None

Disconnect the global data connection.

Return type:

None

CScript:

datapool::logout