How to Implement SIDL Objects in Python

To build server side Python, you must have Python compiled as a shared library or dynamically link library. The standard Python build only builds the necessary shared library on a few platforms -- none of which are target platforms for Babel. Some Linux distributions include a Python shared library, and it is possible to make a Python shared library on Solaris. The Python shared library should contain the objects from libpythonx.y.a where x.y is your Python version. Making a shared library is different on each platform, so it is not covered here.

To implement an object in Python, first you must run Babel to create the Python server side bindings 12.1.

% babel -server=python file.sidl
or simply
% babel -s=python file.sidl

This creates the IOR, Python skeleton (pSkel), and Python launch (pLaunch) files in your currect directory, and it will create tree of subdirectories based on the package hierarchy found in file.sidl. The IOR, pSkel and pLaunch files must be compiled and place in a shared library (in most cases).

The tree of subdirectories created by Babel includes Python implementation files whose name ends with _Impl.py and Python extension modules for the Python client side binding (_Module.h and _Module.c). The extension modules need to be compiled as above in section 11.5, and you need to fill in the implementations in the _Impl.py files.

Babel generates the outline of the implementation. It creates a class definition and empty methods for you to fill in the each _Impl.py file. If you put your code between the comments as indicated, your code will be preserved if you rerun Babel. Any changes out side the comment blocks will be lost if you rerun Babel. Here is an example of a method implementation:


  def passeverywhere(self, d1, d3):
    #
    # SIDL EXPECTED INCOMING TYPES
    # ============================
    # double d1
    # double d3
    #

    #
    # SIDL EXPECTED RETURN VALUE(s)
    # =============================
    # (_return, d2, d3)
    # double _return
    # double d2
    # double d3
    #

    # DO-NOT-DELETE splicer.begin(passeverywhere)
    if (d1 == 3.14):
      retval = 3.14
    else:
      retval = 0
    return (retval, 3.14, -d3)
    # DO-NOT-DELETE splicer.end(passeverywhere)

Babel generated everything except the code that appears between the splicer.begin and splicer.end comments.



babel-0.10.2
users_guide Last Modified 2005-03-23

http://www.llnl.gov/CASC/components
components@llnl.gov