
|
 |
Monday, April 2, 2001
It's been a year since ORBit-Python's last version, and a release is
long overdue. 0.2.0 brings a slew of new features, not the least of
which is closer compliance to the Python mapping spec, enhanced dynamic IDL
(load_idl is no longer necessary in most cases), a small API for
extension modules, compatability with Python 2.x, as well as dozens of
fixes for bugs and memory leaks.
The website has also undergone a face lift. It makes heavy use
of CSS, so you'll want to browse it using a decent browser like Mozilla,
Konqueror, or Internet Explorer (in other words, one that is not
Netscape 4). I've also started writing documentation. It's scarce at
the moment, but if you have any suggestions for improvements, please
let me know.
|
| 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.
|
| 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 sys, 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(sys.argv, CORBA.ORB_ID)
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 sys, CORBA, Bank
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
# 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.
|
|