Thread: [Orbit-python-list] How to use IDL unions with orbit-python?
Status: Inactive
Brought to you by:
tack
From: <ml...@kn...> - 2002-01-23 23:25:07
|
Hi, I'm new to Orbit-Python (and new to Orbit and new to Python), so my question may be a frequently asked one. I have sth. like that: module M { struct S { enum E1 { A, B } e; }; union U switch (enum E2 { A, B }) { case A: ...; case B: ...; }; ... }; How can I access A and B in client and server code in both cases? I tried different variants like M.A and M.U.A, but didn't succeed. Thanks in advance! |
From: Roland M. <99....@ai...> - 2002-01-25 17:02:53
|
ml (2002-01-24 00:20:45 +0100) : [Accessing union members] > How can I access A and B in client and server code in both cases? I > tried different variants like M.A and M.U.A, but didn't succeed. I'm afraid I can't give you a definitive answer since I don't use unions, but you might consider reading the CORBA Python language mapping specification. I seem to remember it explains precisely the syntax to use in order to access union members. You can find this spec on the OMG site, and there's a link to it from the ORBit-Python homepage, at <URI:http://orbit-python.sault.org/>. Roland. -- Roland Mas With the arrest of Dimitry Sklyarov it has become apparent that it is not safe for non US software engineers to visit the United States. - Alan Cox |
From: <ml...@kn...> - 2002-01-26 12:20:12
|
Hallo, thanks for the quick reply! On Fri, Jan 25, 2002 at 06:02:48PM +0100, Roland Mas wrote: > I'm afraid I can't give you a definitive answer since I don't use > unions, but you might consider reading the CORBA Python language > mapping specification. I seem to remember it explains precisely the I should have written, that I already read the spec, and also found some examples both for orbit-python and omniORBpy, but no document showed the use of "embedded" enum values e.g. in a union: module M { union U switch (enum E { A, B }) { case A: ...; case B: ...; }; }; So it's more a problem with enums than with unions, because here I have the same problem: module M { struct S { enum E { A, B } X; }; }; I think I have to put the enum outside of the union or the struct, but that's not so nice. Cheers! |
From: <ml...@kn...> - 2002-01-28 19:00:06
|
Hi, is there a port of orbit-python to orbit2? AFAIK, "corbaloc:", "corbaname:" etc. are not supported by orbit1. Thanks in advance! |
From: Christian R. R. <ki...@as...> - 2002-01-28 19:22:19
|
On Mon, 28 Jan 2002, ml wrote: > is there a port of orbit-python to orbit2? AFAIK, > "corbaloc:", "corbaname:" etc. are not supported by > orbit1. There is, check out gnome CVS, module "orbit-python" IIRC. Am I right, Johan? Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL |
From: Johan D. <zil...@ho...> - 2002-01-28 19:58:39
|
m=E5n 2002-01-28 klockan 20.23 skrev Christian Robottom Reis: > On Mon, 28 Jan 2002, ml wrote: >=20 > > is there a port of orbit-python to orbit2? AFAIK, > > "corbaloc:", "corbaname:" etc. are not supported by > > orbit1. >=20 > There is, check out gnome CVS, module "orbit-python" IIRC. Am I right, > Johan? Yepp. export CVSROOT=3D':pserver:ano...@an...:/cvs/gnome' cvs login cvs -z3 co orbit-python Note. The module has the same name as the one in orbit-python.sourceforge.net >=20 > Take care, > -- > Christian Reis, Senior Engineer, Async Open Source, Brazil. > http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL >=20 |
From: <ml...@kn...> - 2002-01-31 20:30:17
|
On Mon, Jan 28, 2002 at 08:58:26PM +0100, Johan Dahlin wrote: > mån 2002-01-28 klockan 20.23 skrev Christian Robottom Reis: > > On Mon, 28 Jan 2002, ml wrote: > > > > > is there a port of orbit-python to orbit2? AFAIK, > > > "corbaloc:", "corbaname:" etc. are not supported by > > > orbit1. For those who need only "corbaloc:" (that's ok for me at the moment) without all the other goodies of orbit2: I hacked a few lines of python code to emulate that behaviour. I just split the "corbaloc:" string and call genior (from omniORB3) using popen with the parameters from the string and read the generated IOR back to the client program. Cheers! |
From: <ml...@kn...> - 2002-01-29 18:25:06
|
Hi, I want to have a CORBA client that does not need to know the IOR of the server, but without the overhead of a CORBA naming service. If the server has a single factory object with a fixed ID the server uses a fixed client-known TCP port, the client should reach the service using sth. like: $ ./client corbaloc::192.168.10.20:7777/Echo Unfortunately my orbit-python based server doesn't do what I hoped for: #!/usr/bin/env python import random, CORBA from _GlobalIDL__POA import Echo import sys class Echo_Impl(Echo): def echoString(self, astring): outnum = random.randint(0, 100) / 100.0 print "[server] %s -> %f" % (astring, outnum) return self._this(), outnum sys.argv.append("-ORBIIOPIPv4=1") sys.argv.append("-ORBIIOPUSock=0") sys.argv.append("-ORBIPv4Port=7777") orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) servant = Echo_Impl() poa = orb.resolve_initial_references("RootPOA") poa.activate_object_with_id("Echo", servant) print orb.object_to_string(servant._this()) poa.the_POAManager.activate() orb.run() If I look at the ior string (using catior, ior-decode, or ior-decode-2), the TCP port is e.g. 1188, not 7777, and the object key is no "Echo", but I don't know what. I believe that I misunderstood at least two CORBA or orbit-python concepts, right? Could someone enlighten me, please? Thanks in advance! |
From: Christian R. R. <ki...@as...> - 2002-01-30 22:40:23
|
On Tue, 29 Jan 2002, ml wrote: > sys.argv.append("-ORBIIOPIPv4=1") > sys.argv.append("-ORBIIOPUSock=0") > sys.argv.append("-ORBIPv4Port=7777") I hacked 0.3.1 to fix this, but it could be that the parameter is not being passed along. I'm not sure if that's your problem. What happens if you don't pass those in? Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL |
From: <ml...@kn...> - 2002-01-31 20:25:20
|
On Wed, Jan 30, 2002 at 08:41:09PM -0200, Christian Robottom Reis wrote: > On Tue, 29 Jan 2002, ml wrote: > > > sys.argv.append("-ORBIIOPIPv4=1") > > sys.argv.append("-ORBIIOPUSock=0") > > sys.argv.append("-ORBIPv4Port=7777") > > I hacked 0.3.1 to fix this, but it could be that the parameter is not > being passed along. I'm not sure if that's your problem. What happens if > you don't pass those in? The first two arguments do have the expected effect, the third not. Cheers. |
From: Christian R. R. <ki...@as...> - 2002-01-31 20:29:22
|
On Thu, 31 Jan 2002, ml wrote: > > I hacked 0.3.1 to fix this, but it could be that the parameter is not > > being passed along. I'm not sure if that's your problem. What happens if > > you don't pass those in? > > The first two arguments do have the expected effect, the > third not. It could be an orbit bug; can you try and bring it up with them? We may not be passing in the parameter, but I find that very hard to believe if the others do and we don't manipulate them. Changing order does nothing, I assume? Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL |
From: <ml...@kn...> - 2002-01-31 21:05:30
|
On Thu, Jan 31, 2002 at 06:30:15PM -0200, Christian Robottom Reis wrote: > On Thu, 31 Jan 2002, ml wrote: > > > > I hacked 0.3.1 to fix this, but it could be that the parameter is not > > > being passed along. I'm not sure if that's your problem. What happens if > > > you don't pass those in? > > > > The first two arguments do have the expected effect, the > > third not. > > It could be an orbit bug; can you try and bring it up with them? > > We may not be passing in the parameter, but I find that very hard to > believe if the others do and we don't manipulate them. Changing order does > nothing, I assume? Right, that doesn't help either. I hope, I will find time to test it with (C-)Orbit(1). Cheers. |
From: <ml...@kn...> - 2002-01-31 21:25:15
|
On Thu, Jan 31, 2002 at 06:30:15PM -0200, Christian Robottom Reis wrote: > On Thu, 31 Jan 2002, ml wrote: > > > > I hacked 0.3.1 to fix this, but it could be that the parameter is not > > > being passed along. I'm not sure if that's your problem. What happens if > > > you don't pass those in? > > > > The first two arguments do have the expected effect, the > > third not. > > It could be an orbit bug; can you try and bring it up with them? > > We may not be passing in the parameter, but I find that very hard to > believe if the others do and we don't manipulate them. Changing order does > nothing, I assume? It seems to be either a problem with (C-)Orbit or with my understanding of it. I compiled the echo-server.c from the orbit-0.5.13 test suite and ran it as follows: ./echo-server -ORBIPv4Port=7777 -ORBIIOPIPv4=1 -ORBIIOPUSock=0 Neither is the object id "myEchoString" as it should, because PortableServer_POA_activate_object_with_id() has been called nor is the open port 7777, but 1166 or so. The ior-decode utility and a check using netstat -an shows this clearly. IP and not UNIX sockets is used, at least. Cheers! |
From: Christian R. R. <ki...@as...> - 2002-01-31 21:29:38
|
On Thu, 31 Jan 2002, ml wrote: > It seems to be either a problem with (C-)Orbit or with my > understanding of it. I compiled the echo-server.c from > the orbit-0.5.13 test suite and ran it as follows: > > ./echo-server -ORBIPv4Port=7777 -ORBIIOPIPv4=1 -ORBIIOPUSock=0 > > Neither is the object id "myEchoString" as it should, > because PortableServer_POA_activate_object_with_id() has > been called nor is the open port 7777, but 1166 or so. > The ior-decode utility and a check using netstat -an shows > this clearly. IP and not UNIX sockets is used, at least. Could you file a bug on bugzilla.gnome.org and CC: me on it please? Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL |
From: Jochen V. <jv...@we...> - 2002-01-28 19:12:49
|
Hello, On Thu, Jan 24, 2002 at 12:20:45AM +0100, ml wrote: > Hi, >=20 > [...] >=20 > How can I access A and B in client and server code in > both cases? I tried different variants like M.A and > M.U.A, but didn't succeed. Part of the problem may be the bug, which is described at http://bugs.debian.org/123848 The access to union members does not follow the CORBA python language mapping specification. This really should be fixed. Jochen --=20 Omm (0)-(0) http://www.mathematik.uni-kl.de/~wwwstoch/voss/privat.html |
From: Johan D. <jd...@te...> - 2002-01-28 20:02:07
Attachments:
union-diff
|
m=E5n 2002-01-28 klockan 20.07 skrev Jochen Voss: > Hello, >=20 > On Thu, Jan 24, 2002 at 12:20:45AM +0100, ml wrote: > > Hi, > >=20 > > [...] > >=20 > > How can I access A and B in client and server code in > > both cases? I tried different variants like M.A and > > M.U.A, but didn't succeed. >=20 > Part of the problem may be the bug, which is > described at >=20 > http://bugs.debian.org/123848 >=20 > The access to union members does not follow > the CORBA python language mapping specification. > This really should be fixed. >=20 Could you try the attached patch and see if it works better for you? > Jochen > --=20 > Omm > (0)-(0) > http://www.mathematik.uni-kl.de/~wwwstoch/voss/privat.html |
From: Jochen V. <jv...@we...> - 2002-01-28 23:11:55
|
Hello, thank you for the quick fix. On Mon, Jan 28, 2002 at 09:02:01PM +0100, Johan Dahlin wrote: > m=E5n 2002-01-28 klockan 20.07 skrev Jochen Voss: > > Part of the problem may be the bug, which is > > described at > >=20 > > http://bugs.debian.org/123848 > >=20 > > The access to union members does not follow > > the CORBA python language mapping specification. > > This really should be fixed. > >=20 > Could you try the attached patch and see if it works better for you? Yes, I tried it and it is a big improvement. The _d and _u attributes have the correct names, now. But there are still problems left. I will use the following IDL file to explain. module TestUnion { interface Frosch { enum E2 { A, B }; union MyUnion switch (E2) { case A: long x; case B:=20 string s; }; attribute MyUnion U; }; }; Now, Section 1.3.5 of the CORBA python language mapping says: Union types are mapped to classes with two attributes. [ ... _d and _v are explained ... ] For each branch, there is an additional attribute, which can only be accessed if the branch has been set. This additional attribute seems to be no implemented: voss@tatonka [~/src/python/test-union] python Python 2.1.2 (#1, Jan 18 2002, 18:05:45)=20 [GCC 2.95.4 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import CORBA, TestUnion >>> x=3DTestUnion.Frosch.MyUnion(TestUnion.Frosch.B,"Hallo") >>> x <__main__.MyUnion instance at 0x80a606c> >>> x._d 1 >>> x._v 'Hallo' >>> x.s=20 Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: MyUnion instance has no attribute 's' The way I read section 1.3.5, x.s should have been 'hallo'. Next: the specification continues: [...] * If the discriminant is not listed [in a case label], and there is no default, the value is "None". This does not work, too: voss@tatonka [~/src/python/test-union] python Python 2.1.2 (#1, Jan 18 2002, 18:05:45)=20 [GCC 2.95.4 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import CORBA, TestUnion >>> x=3DTestUnion.Frosch.MyUnion() >>> x._d=3D2 AttributeError: MyUnion instance has no attribute '_v' >>> x._v Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: MyUnion instance has no attribute '_v' Even if it is simply not inplemented, the first error message looks strange. I hope this helps, Jochen --=20 Omm (0)-(0) http://www.mathematik.uni-kl.de/~wwwstoch/voss/privat.html |
From: Christian R. R. <ki...@as...> - 2002-01-31 11:53:54
|
On Thu, 24 Jan 2002, ml wrote: > module M { > struct S { > enum E1 { A, B } e; > }; > union U switch (enum E2 { A, B }) { > case A: ...; > case B: ...; > }; > ... > }; We had a bug reported on unions not working as expected a while back. While this may not have any impact on you, I'm not very sure. If you are following the spec and it doesn't work, look at bug 13 (on bugzilla.sault.org) and if that's it, add a comment. Otherwise, file a new one and I'll get to looking at it. Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL |