Nirvana Python : Creating a Session

To interact with a Nirvana Server, the first thing to do is initialize a Nirvana Session object, which is effectively your logical and physical connection to one or more Nirvana Realms.

Creating a Nirvana Session Object

A Nirvana Session object (called NirvanaSession) is contained within the NirvanaPython library so you must first include the library and then initiate a new NirvanaSession.

    from NirvanaPython import *
    NirvanaModule = NirvanaSession()

If the NirvanaPython library is not in the same directory as the application you are writing then you will need to make sure the directory containing the library is in the Python sys path:

    import sys
    sys.path.append('..\\bin\\Win32\\Python26\\')

If you have problems importing the NirvanaPython library then it may be that one of the other dependencies are missing. Please make sure you have dealt with the prerequisites

Connecting to a Nirvana Realm

Once the NirvanaSession object has been initialised, you can connect to a Nirvana Realm as follows:

    rname="nsp://localhost:9000"
    NirvanaModule.connect(rname)

For information of the parameters you can pass to the connect() function e.g a user name, you can enter:

    help(NirvanaModule.connect)