[omniORB] How to pass sequence<any> as parameter from Python
Joel Wagner
Joel.Wagner at veritas.com
Mon Apr 12 10:44:00 BST 2004
I have a Python client that I'm trying to use to pass a 'sequence<any>' to a
server.
Here is the IDL:
module V {
typedef sequence<any> ANY_SEQ;
struct Rec {
long a;
long b;
long c;
};
interface X {
// long Exec( in long Cmd, inout sequence<any> Args
); // causes IDL compilation error
// $ omniidl -bomniidl_be/python xxx.idl
// xxx.idl:10: Syntax error in operation
parameters
// omniidl: 1 error.
long Exec( in long Cmd, inout ANY_SEQ Args );
};
};
Here is the client code:
import sys
import omniORB
from omniORB import CORBA
from omniORB import any
import V
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
ior = sys.argv[1]
obj = orb.string_to_object(ior)
server = obj._narrow(V.X)
rec = V.Rec
rec.a = 0
rec.b = 1
rec.c = 2
if sys.argv[2] == '1':
print '--- try #1'
xany = any.to_any(rec)
resp = server.Exec(1, [xany])
print 'resp', resp
if sys.argv[2] == '2':
print '--- try #2'
tc = CORBA.TypeCode(CORBA.id(V.ANY_SEQ))
xany = CORBA.Any(tc, [rec])
resp = server.Exec(1, xany)
print 'resp', resp
First question is why does the following IDL cause a compilation error, must
I use the ANY_SEQ typedef?
long Exec( in long Cmd, inout sequence<any> Args ); // causes IDL
compilation error
Second question is what is the proper way to pass a sequence<any> as a
parameter from Python? Both try #1 and #2 produce omniORB.CORBA.BAD_PARAM:
Minor: BAD_PARAM_WrongPythonType exceptions.
Thanks in advance for any assistance,
Joel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20040412/f6f71683/attachment.htm
More information about the omniORB-list
mailing list