Python bindings for ORBit

Documentation
* Dynamic IDL
* CORBA
* CORBA.ORB
* POA
* Servants

* CVS ChangeLog

 

Project Links
* SourceForge
* Downloads
* Bugzilla
* CVS
* Mailing List

 

Links
* ORBit2
* ORBit2 Resources
* Perl bindings
* C++ bindings
ORBit-Python released!
Tuesday, November 13, 2001

0.3.1 is a bugfix release with the following changes from 0.3.0: revamped test suite; marshalling fixes for double and boolean; _narrow() segv fix; command line arguments are correctly passed to ORBit; CORBA.Any memory fixes; null and void typecodes handled; a few IDL importing bugs fixed. For more details, see the ChangeLog.

Thanks to the ORBit-Python development team for making this release possible (and for continuously nagging me to release). As always, email me or join the orbit-python mailing list for any comments or questions. You can also chat with other users and developers by joining #orbit-python on irc.openprojects.net. See you there!

 

Overview
Python is an object-oriented and dynamically typed language. These two features make it quite ideal for seamless CORBA bindings. Following the approach used in CORBA::ORBit (the Perl bindings), ORBit-Python does away with the need for an IDL compiler. Throw away your stubs and skeletons! ORBit-Python also takes the dynamic approach one step further by automatically discovering available IDL modules and transparently loading them when the corresponding modules get imported. When the IDL files are loaded, the appropriate objects and classes are created dynamically. This makes rapid prototyping with CORBA a reality.

Most of the ORBit types are implemented, with the exception of the fixed and long double types. (Wide types are partially supported and currently experimental.) Also, only a fairly small subset of the POA is implemented. Even in its current state, however, it is already being used successfully in several commercial systems.

Considerable effort has been taken to adhere to the Python Language Mapping Specification and remain compatible with other Python ORBs, but because of its dynamic nature, certain extensions have been made that are specific to ORBit-Python. Still, if portability is important to you, code that uses ORBit-Python can be moved to and from different ORBs with little or no modification.

ORBit-Python began as the thesis project for my undergraduate degree at Algoma University in Ontario Canada, who now happens to be my employer. And although they don't exactly know it yet, some of the current work is even funded by them. :)

If you have any feedback about ORBit-Python, feel free to email me, or subscribe to the mailing list.

 

Example
Everyone wants to see screenshots, but with a project like this, an example is the next best thing. Let's suppose we have the following IDL called Bank.idl:

 

module Bank {
   interface Account {
      typedef double Amount;
      readonly attribute Amount balance;

      exception InsufficientFunds { Amount overdraft; };
      void withdraw(in Amount x) raises (InsufficientFunds);
   };
};

The server side might look like:

 

import CORBA, Bank, Bank__POA
 
class Account(Bank__POA.Account):
   def __init__(self):
      self.balance = 100.0
   
   def withdraw(self, amount):
      if self.balance - amount < 0:
         d = Bank.Account.InsufficientFunds()
         d.overdraft = amount - self.balance
         raise Bank.Account.InsufficientFunds, d
      else:
         self.balance = self.balance - amount
 
orb = CORBA.ORB_init()
poa = orb.resolve_initial_references("RootPOA")
 
ref = Account()._this()    # implicit activation
# Write the IOR to a file to be read by the client
open("/tmp/orbit-python.ior", "w").write(orb.object_to_string(ref))
 
poa._get_the_POAManager().activate()
orb.run()

And the client might look like:

 

import CORBA, Bank
 
orb = CORBA.ORB_init()
# Read the IOR written by the server
ior = open("/tmp/orbit-python.ior").readline()
account = orb.string_to_object(ior)
 
print "Current balance:", account.balance
try:
   account.withdraw(30.00)
   print "New balance:", account.balance
except Bank.Account.InsufficientFunds, data:
   print "Withdraw failed: overdrawn by", data.overdraft

Remember, no IDL compiling step is necessary because IDL is processed at run-time. How does ORBit-Python know where the IDL file is located for the Bank module? Using its unique IDL preprocessing step, ORBit-Python discovers all available IDL modules and what files need to be processed to correctly import the module. It scans the directories specified by the IDLPATH environment variable, or uses an intelligent default if no IDLPATH is specified.

 

Downloads
* Source tarball (orbit-python-0.3.1.tar.gz) (216k)

* i386 RPM for RedHat 7.x (orbit-python-0.3.1-1-rh7.i386.rpm) (177k)
* i386 devel RPM for RedHat 7.x (orbit-python-devel-0.3.1-1-rh7.i386.rpm) (15k)
* SRPM for RedHat 7.x (orbit-python-0.3.1-1-rh7.src.rpm) (264k)

* Debian packages are available under python-orbit (and python-orbit-dev) using apt-get.

* The report submitted for my undergrad thesis as part of this project (193k)