[omniORB] omniORBpy newbie: returning interface from remote call

Duncan Grisby duncan at grisby.org
Sat Apr 14 20:14:25 BST 2007


On Thursday 12 April, gabriele renzi wrote:

> I just started experimenting with omniORBpy today, everything seemed
> to be working fine but now I hit a strange problem. My IDL file looks
> like this

[...]
> but then if I try to call 
> calc = cf.client_instance('name')
> I get a 
> CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, 
> CORBA.COMPLETED_MAYBE) exception.
> 
> The code in CalcFactoryImpl, the subclass of the
> abstract PSD__POA.CalcFactory is like this:
> def client_instance(self,key):
>  client=CalcImpl() # PSD__POA.Calc subclass
>  return client

client is a servant, i.e. a programming language object. It is different
from a CORBA object reference, which is what you must return from your
factory operation.

To get an object reference, you must activate your servant in a POA. In
your simple example, you can activate it in the RootPOA and return an
object reference with a call to _this():

def client_instance(self,key):
    client=CalcImpl() # PSD__POA.Calc subclass
    return client._this()

In general, you should learn about POAs and their policies, otherwise
you'll be bitten by object lifecycles sooner or later. Ciaran McHale has
written a good free book that explains it all very well. Take a look
here:

  http://www.ciaranmchale.com/corba-explained-simply/

and especially this chapter:

  http://www.ciaranmchale.com/corba-explained-simply/concepts-for-server-side-programming.html

The slides and code for a tutorial I gave might be useful for you too:

  http://www.grisby.org/presentations/py10code.html


Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list