Thanks everyone, I've raised a bug report at http://bugzilla.gnome.org/show_bug.cgi?id=357944

Now, back to learning more about CORBA

Cheers,
Russell

Gustavo J. A. M. Carneiro wrote:
On Ter, 2006-09-26 at 10:03 +1000, Russell Strong wrote:
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")

If you change this code:

ref = Counter()._this()

to this:

counter = Counter()
ref = counter._this()

Then it works (after you fix the rest of the code,
s/Test.TestInterface.Overflow/Test.Counter.Overflow/).

The reason is that this expression "Counter()._this()" creates a
Counter() servant, takes a CORBA object reference to it, but then the
servant's reference count drops to zero and the servant is deallocated
and deactivated.  So the client ends up receiving a reference to a dead
object.

I'm not completely sure yet, but this looks like a PyORBit bug.  Could
you open a bug report in bugzilla?  Thanks.


_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to