[pygtk] ORBit and python
Russell Strong
russell at strong.id.au
Tue Sep 26 08:03:10 WST 2006
Hi,
I've been pulling my hair out the last couple of days trying to get a
simple python/ORBit example working.
The server code ( see below ) show the following error
Traceback (most recent call last):
File "server", line 14, in increment
self.count += 1
AttributeError: 'Counter' object has no attribute 'count'
Adding a line print dir(self) to increment shows there really is no
count. Huh???
The client ( see below ) shows:
Traceback (most recent call last):
File "client", line 13, in ?
counter.increment()
CORBA.UNKNOWN
HELP !!!
Client Code
----------------
#!/usr/bin/env python
import ORBit
ORBit.load_file ('Test.idl')
import CORBA, Test
orb = CORBA.ORB_init()
ior = open('/tmp/orbit-python.ior').readline()
counter = orb.string_to_object(ior)
for i in xrange(10001):
try:
counter.increment()
except Test.Counter, data:
print 'Overflow : ', data.count
Server Code
----------------
#!usr/bin/env python
import ORBit
ORBit.load_file('Test.idl')
import CORBA, Test, Test__POA
class Counter(Test__POA.Counter):
def __init__(self):
Test__POA.Counter.__init__(self)
self.count = 0
def increment(self):
self.count += 1
if self.count > 10000:
e = Test.TestInterface.Overflow()
e.count = self.count
raise Test.TestInterface.Overflow, e
orb = CORBA.ORB_init()
poa = orb.resolve_initial_references("RootPOA")
ref = Counter()._this()
open("/tmp/orbit-python.ior", "w").write(orb.object_to_string(ref))
poa._get_the_POAManager().activate()
orb.run()
IDL
-----
module Test {
interface Counter {
readonly attribute long count;
exception Overflow { long count; };
void increment () raises (Overflow);
};
};
More information about the pygtk
mailing list