2 # Copyright (C) 2006-2008 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Import the CORBA module
23 from omniORB import CORBA
29 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
31 # Obtain a reference to the root naming context
32 obj = orb.resolve_initial_references("NameService")
33 rootContext = obj._narrow(CosNaming.NamingContext)
35 if rootContext is None:
36 print "Failed to narrow the root naming context"
39 # Resolve the name "test.my_context/Echo.Object"
40 name = [CosNaming.NameComponent("test", "my_context"),
41 CosNaming.NameComponent("Echo", "Object")]
44 obj = rootContext.resolve(name)
46 except CosNaming.NamingContext.NotFound, ex:
47 print "Name not found"
50 # Narrow the object to an eo::Echo
51 echo = obj._narrow(eo.Echo)
54 print "Object reference is not an eo::Echo"
57 # Invoke the echoString operation
58 message = "Hello from Python"
59 result = echo.echoString(message)
61 print "I said '%s'. The object said '%s'." % (message,result)
78 s1=eo.S1(x=1,y=2,s="aa",b=True,vd=[1,2])
84 s3=eo.S3(x=1,y=2,s="aa",b=True,ob=None)
85 r=echo.echoStruct2(s3)
93 s3=eo.S3(x=1,y=2,s="aa",b=True,ob=ob)
94 r=echo.echoStruct2(s3)
97 s3=eo.S3(x=1,y=2,s="aa",b=True,ob=oc)
98 r=echo.echoStruct2(s3)
101 r=echo.echoObjectVec([ob,ob])
104 r=echo.echoObjectVec([oc,oc])
107 r=echo.echoObjectVec([ob,oc])