Communication with a RAD instance is provided through the RADConnection class. There are various mechanism to get different types of connections to RAD. Each mechanism returns a RADConnection instance which provides a standard interface to interact with RAD.
The preferred approach for managing a connection is to use the "with" keyword. The connection makes use of system resources and this style ensures that the resource is closed correctly when the object goes out of scope. If this style isn't used, then the system resources can be reclaimed explicitly with the close() method.
Implicit authentication is performed against your user id and most RAD tasks you request with this connection are performed with the privileges available to your user account.
Example 3-31 Creating a Local Connection>>> import rad.connect as radcon >>> with radcon.connect_unix() as rc:
When connecting to a remote instance, there is no implicit authentication, so the connection is not useful until authentication is performed. The rad.auth module provides a utility class (RadAuth) which may be used to perform a PAM login. If you supply a username and password, authentication proceeds in a non-interactive fashion. If either is absent, you will receive a console prompt for the missing information.
Example 3-32 Remote Connection over TLS>>> import rad.connect as radcon >>> import rad.auth as rada >>> rc=radcon.connect_tls("henry") >>> # Illustrate examining RadConnection state. >>> print rc <open RadConnection > >>> auth = rada.RadAuth(rc) >>> auth.pam_login("garypen", "xxxpasswordxxx") >>> <now authenticated and can use this connection> >>> rc.close() >>> print rc <closed RadConnection > >>>