[omniORB] Problem with inheritance

W. Borgert debacle at debian.org
Sat Mar 13 14:32:20 GMT 2004


Somehow, this mail of 2004-03-10 11:13:09 didn't make it to
the mailing list:

On Wed, Mar 10, 2004 at 11:31:44AM -0800, Thomas Lockhart wrote:
> I'm not sure what the IOR contains. In some of my other code (based on 
> TAO,not omniORB) it contains the parent interface, not the derived one. 
> But you can rip it apart to see using catior or iordump.

I looked at the IOR: It contains the actual interfaces type
id (the inherited one, not the parent).  Otherwise a client
would have to call "widen" instead of narrow :-)

Anyway, I think I have answered my own question: I have two
IDL files a/echo-a.idl:

// parent interface
interface EchoA {
  string echoString(in string mesg);
};

And b/echo-b.idl:

// derived interface
#include <../a/echo-a.idl>
interface EchoB : EchoA {
  long echoNumber(in long n);
};

I have one server b/server-b.py:

#!/usr/bin/env python
import string, sys, CORBA, _GlobalIDL__POA
class EchoB_Impl(_GlobalIDL__POA.EchoB):
    def echoString(self, a_string):
        return string.upper(a_string)
    def echoNumber(self, a_number):
        return a_number * 2
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
servant = EchoB_Impl()
poa = orb.resolve_initial_references("RootPOA")
poa.activate_object_with_id("Echo", servant)
print orb.object_to_string(servant._this())
poa._get_the_POAManager().activate()
orb.run()

A client for the derived interface b/client-b.py:

#!/usr/bin/env python
import CORBA, _GlobalIDL, sys
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
echo = orb.string_to_object(sys.argv[1])._narrow(_GlobalIDL.EchoB)
print echo.echoString("hello")
print echo.echoNumber(21)

And finally (solving my problem) a client a/client-a.py:

#!/usr/bin/env python
import CORBA, _GlobalIDL, sys
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
echo = orb.string_to_object(sys.argv[1])._narrow(_GlobalIDL.EchoA)
print echo.echoString("hello")

I compiled the IDLs:

cd a; omniidl -bpython echo-a.idl
cd b; omniidl -I. -bpython -Wbinline echo-b.idl

And everything ran fine.  The initial problem must have
another cause.  We'll see.  Thanks again for your help!

Cheers,
-- 
W. Borgert <debacle at debian.org>, http://people.debian.org/~debacle/



More information about the omniORB-list mailing list