[omniORB] how to pass python list through CORBA IDL?

Deepan N Seeralan nsdeeps at gmail.com
Wed Jan 7 11:59:58 GMT 2009


Hello Duncan and Martin,

Thanks for your answers.
Here is my server class.
It just takes a list and append a new item to the list.
----------------------------------------------------------------------------------
class Echo_i (Example__POA.Echo):
    def echoString(self, mesg):
        print "echoString() called with message:", mesg
        mesg.append("new")
        return mesg

My objective is to pass a sequence (i.e list) to the server method and
modify the list from there. I suppose python lists are passed by reference
by default. The changes that I am doing to the list within the server method
should be reflected on the client without actually returning the list. But
when I tried it did not happen that way. I had to return the list to the
client to update the list on its side. I am not sure whether this is the
expected behavior or am i doing something wrong here. Could anyone please
help me here?

After few trials, I was able to get rid of the CORBA_BAD_PARAM error. Here
is my new IDL and client code. Server code is same as what I pasted above.
---IDL--------
module Example {
  typedef sequence<string> sample;
  interface Echo {
    void echoString(inout sample mesg);
  };
};

----Client code--------------
message = ["hello"]
result  = eo.echoString(message)
print "I said '%s'. The object said '%s'." % (message,result)

-------- output from client execution ---
I said '['hello']'. The object said '['hello', 'new']'.

Thanks a lot once again for your help.

Regards,
Deepan


On Wed, Jan 7, 2009 at 7:37 AM, Duncan Grisby <duncan at grisby.org> wrote:

> On Tuesday 6 January, "Deepan N Seeralan" wrote:
>
> > This example works just fine without any modifications. However, if i try
> to
> > change the parameters of the method 'echoString' from string to a
> sequence, I
> > get CORBA_BAD_PARAM error.
>
> That means the Python type of either the arguments or the return value
> do not match the IDL.
>
> > Here is the new IDL and piece of client code where i invoke the method
> > echoString.
> > module Example {
> >   typedef sequence<string> sample;
> >   interface Echo {
> >     void echoString(inout sample mesg);
> >   };
> > };
>
> Did you really mean to use inout there?  That means the sequence is
> returned from the server back to the client.
>
> > .. client code:
> > message = ["hello"] #python list
> > result  = eo.echoString(message)
> > print "I said '%s'. The object said '%s'." % (message,result)
> >
> > I referred to the CORBA-Python mapping document which says that list and
> > tuples are the equivalent objects of CORBA sequence. However, when I run
> the
> > server and client, it throws the error omniORB.CORBA.BAD_PARAM:
> > CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType,
> CORBA.COMPLETED_MAYBE).
>
> You probably aren't returning the list from your servant method. What
> does your servant class look like?
>
> You can get more information about where the exception came from by
> running your code with command line arguments -ORBtraceExceptions 1
>
> Cheers,
>
> Duncan.
>
> --
>  -- Duncan Grisby         --
>  -- duncan at grisby.org     --
>   -- http://www.grisby.org --
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20090107/9a72b9fe/attachment.htm


More information about the omniORB-list mailing list