Discussion:
[omniORB] omniORBpy newbie: returning interface from remote call
gabriele renzi
2007-04-13 02:46:22 UTC
Permalink
Hi everyone,

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

module PSD {
interface Calc {
string myop(in string name,in string other);
};
interface CalcFactory {
Calc client_instance(in string cname);
};
};
omniidl seems to compile the idl fine, and I can get
the CalcFactory correctly via
obj= orb.string_to_object(ior)
cf = obj.narrow(PSD.CalcFactory)

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

Someone has a clue on what I may be doing wrong? Sorry
if I'm posing a dummy question.


___________________________________________________________
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
Duncan Grisby
2007-04-15 00:14:15 UTC
Permalink
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
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 --
-- ***@grisby.org --
-- http://www.grisby.org --
gabriele renzi
2007-04-15 17:14:57 UTC
Permalink
Post by gabriele renzi
Post by gabriele renzi
I just started experimenting with omniORBpy today,
everything seemed
Post by gabriele renzi
to be working fine but now I hit a strange
problem. My IDL file looks
Post by gabriele renzi
like this
[...]
Post by gabriele renzi
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
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.
yes, I got it in the end, I just expected that this
would have been done by the implementation instead of
me for what relates to method calling.

Thanks a lot for all the links they seem quite useful
and interesting :)



___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/

Loading...